On Wed, May 24, 2023 at 05:18:52PM +1200, dn via Python-list wrote:
Note that the line numbers correctly show the true cause of the
problem, despite both of them being ValueErrors. So if you have to
debug this sort of thing, make sure the key parts are on separate
lines (even if they're all one e
On 2023-05-24 12:10:09 +1200, dn via Python-list wrote:
> Perhaps more psychology rather than coding?
Both. As they say, coding means writing for other people first, for
the computer second. So that means anticipating what will be least
confusing for that other person[1] who's going to read that c
On 2023-05-24 08:51:19 +1000, Chris Angelico wrote:
> On Wed, 24 May 2023 at 08:48, Peter J. Holzer wrote:
> > Yes, that probably wasn't the best example. I sort of deliberately
> > avoided method chaining here to make my point that you don't have to
> > invent a new variable name for every interm
-list On
Behalf Of dn via Python-list
Sent: Wednesday, May 24, 2023 1:19 AM
To: python-list@python.org
Subject: Re: OT: Addition of a .= operator
On 24/05/2023 12.27, Chris Angelico wrote:
> On Wed, 24 May 2023 at 10:12, dn via Python-list
wrote:
>> However, (continuing @Peter'
On 24/05/2023 12.27, Chris Angelico wrote:
On Wed, 24 May 2023 at 10:12, dn via Python-list wrote:
However, (continuing @Peter's theme) such confuses things when something
goes wrong - was the error in the input() or in the float()?
- particularly for 'beginners'
- and yes, we can expand the ab
On Wed, 24 May 2023 at 10:12, dn via Python-list wrote:
> However, (continuing @Peter's theme) such confuses things when something
> goes wrong - was the error in the input() or in the float()?
> - particularly for 'beginners'
> - and yes, we can expand the above discussion to talk about
> error-h
On 24/05/2023 10.21, Rob Cliffe via Python-list wrote:
This sort of code might be better as a single expression. For example:
user = (
request.GET["user"]
.decode("utf-8")
.strip()
.lower()
)
user = orm.user.get(name=user)
LOL. And I thought I was the one with a (self-co
On 23/05/2023 22:03, Peter J. Holzer wrote:
On 2023-05-21 20:30:45 +0100, Rob Cliffe via Python-list wrote:
On 20/05/2023 18:54, Alex Jando wrote:
So what I'm suggesting is something like this:
hash = hashlib.sha256(b'word')
hash.=
On Wed, 24 May 2023 at 08:57, Rob Cliffe wrote:
> > Do you mean "ASCII or UTF-8"? Because decoding as UTF-8 is fine with
> > ASCII (it's a superset). You should always consistently get the same
> > data type (bytes or text) based on the library you're using.
> >
> > ChrisA
> OK, bad example. The
On Wed, 24 May 2023 at 08:48, Peter J. Holzer wrote:
>
> On 2023-05-24 07:12:32 +1000, Chris Angelico wrote:
> > On Wed, 24 May 2023 at 07:04, Peter J. Holzer wrote:
> > > But I find it easier to read if I just reuse the same variable name:
> > >
> > > user = request.GET["user"]
> > > use
On 2023-05-24 07:12:32 +1000, Chris Angelico wrote:
> On Wed, 24 May 2023 at 07:04, Peter J. Holzer wrote:
> > But I find it easier to read if I just reuse the same variable name:
> >
> > user = request.GET["user"]
> > user = str(user, encoding="utf-8")
> > user = user.strip()
> >
This sort of code might be better as a single expression. For example:
user = (
request.GET["user"]
.decode("utf-8")
.strip()
.lower()
)
user = orm.user.get(name=user)
LOL. And I thought I was the one with a (self-confessed) tendency to
write too slick, dense, smart-alec
On Wed, 24 May 2023 at 08:22, Rob Cliffe wrote:
>
>
> > This sort of code might be better as a single expression. For example:
> >
> > user = (
> > request.GET["user"]
> > .decode("utf-8")
> > .strip()
> > .lower()
> > )
> > user = orm.user.get(name=user)
> >
> >
> LOL. And I
On Wed, 24 May 2023 at 07:04, Peter J. Holzer wrote:
> But I find it easier to read if I just reuse the same variable name:
>
> user = request.GET["user"]
> user = str(user, encoding="utf-8")
> user = user.strip()
> user = user.lower()
> user = orm.user.get(name=user)
>
> Each
On 2023-05-21 20:30:45 +0100, Rob Cliffe via Python-list wrote:
> On 20/05/2023 18:54, Alex Jando wrote:
> > So what I'm suggesting is something like this:
> >
> >
> > hash = hashlib.sha256(b'word')
> > hash.=hexdigest()
> >
On 20/05/2023 18:54, Alex Jando wrote:
I have many times had situations where I had a variable of a certain type, all
I cared about it was one of it's methods.
For example:
import hashlib
hash = hashlib.sha256(b'word')
hash = hash.
On 21/05/23 9:18 am, Richard Damon wrote:
This just can't happen (as far as I can figure) for .= unless the object
is defining something weird for the inplace version of the operation,
Indeed. There are clear use cases for overriding +=, but it's hard to
think of one for this. So it would just
On 21/05/23 5:54 am, Alex Jando wrote:
hash.=hexdigest()
That would be a very strange and unprecedented syntax that
munges together an attribute lookup and a call.
Keep in mind that a method call in Python is actually two
separate things:
y = x.m()
is equivalent to
f = x.m
y = f()
But it
On 5/20/23 4:15 PM, Peter J. Holzer wrote:
On 2023-05-20 10:54:59 -0700, Alex Jando wrote:
I have many times had situations where I had a variable of a certain
type, all I cared about it was one of it's methods.
For example:
hash = h
On 2023-05-20 10:54:59 -0700, Alex Jando wrote:
> I have many times had situations where I had a variable of a certain
> type, all I cared about it was one of it's methods.
>
> For example:
>
>
> hash = hash.hexdigest()
> --
different circumstance?
-Original Message-
From: Python-list On
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Saturday, May 20, 2023 2:49 PM
To: python-list@python.org
Subject: Re: Addition of a .= operator
On 2023-05-21 at 06:11:02 +1200,
dn via Python-list wrote:
> On 21
On 2023-05-21 at 06:11:02 +1200,
dn via Python-list wrote:
> On 21/05/2023 05.54, Alex Jando wrote:
> > I have many times had situations where I had a variable of a certain type,
> > all I cared about it was one of it's methods.
> >
> > For example:
> >
> >
On 21/05/2023 05.54, Alex Jando wrote:
I have many times had situations where I had a variable of a certain type, all
I cared about it was one of it's methods.
For example:
import hashlib
hash = hashlib.sha256(b'word')
hash = hash.he
I have many times had situations where I had a variable of a certain type, all
I cared about it was one of it's methods.
For example:
import hashlib
hash = hashlib.sha256(b'word')
hash = hash.hexdigest()
---
24 matches
Mail list logo