Addition of a .= operator

Alex Jando alexjando2007 at gmail.com
Sat May 20 13:54:59 EDT 2023


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()
------------------------------------------------------------
import enum
class Number(enum.Enum):
        One: int = 1
        Two: int = 2
        Three: int = 3
num = Number.One
num = num.value
------------------------------------------------------------

Now to be fair, in the two situations above, I could just access the method right as I declare the object, however, sometimes when passing values into functions, it's a lot messier to do that.

So what I'm suggesting is something like this:

------------------------------------------------------------
import hashlib
hash = hashlib.sha256(b'word')
hash.=hexdigest()
------------------------------------------------------------
import enum
class Number(enum.Enum):
        One: int = 1
        Two: int = 2
        Three: int = 3
num = Number.One
num.=value
------------------------------------------------------------


More information about the Python-list mailing list