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() > ------------------------------------------------------------ > num = num.value > ------------------------------------------------------------ > > So what I'm suggesting is something like this: > > ------------------------------------------------------------ > hash.=hexdigest() > ------------------------------------------------------------ > num.=value > ------------------------------------------------------------
I actually needed to read those twice to get their meaning. I think
hash .= hexdigest()
num .= value
would have been clearer (yes, I nag my colleagues about white-space,
too).
Do you have any examples (preferably from real code) where you don't
assign to a simple variable? I feel that
x += 1
isn't much of an improvement over
x = x + 1
but
self.data[line+len(chars)-1] += after
is definitely an improvement over
self.data[line+len(chars)-1] + self.data[line+len(chars)-1] + after
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
