Open RSAkidinUSA opened 1 year ago
I think what you want to do might be this ?
from aenum import Enum, auto
class A(Enum):
_init_ = 'value comment'
a = 1, 'comment for a'
b = auto(), 'comment for b'
c = auto(), 'comment for c'
seems to work fine ?
I actually came to this issue looking for a solution of your last sentence. If I am getting it right, this might be it :)
from aenum import Enum, AddValue
class tst(Enum):
def _generate_next_value_(name, start, count, last, *args, **kwargs):
return (name,args[0])
_settings_ = AddValue
_init_ = "value other"
FOO = "hohoho"
If auto has non-value arguments and is called successively all following calls will be set to the previous value. e.g.
In the above
A.a
andA.b
are unique, butA.b == A.c
- but if you do the following, everything is fine:Also, if in above you set
d = 2, 'comment for d'
,A.c
is fine, butA.d == A.b
.Somewhat related, it would be nice to be able to write a custom function to handle empty
auto
's / provide default arguments for init.