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.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
------------------------------------------------------------
A custom-class wrapper?
Even, a decorator-able function?
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list