Rustom Mody <rustompm...@gmail.com>: > Given the eg in the docs: > from enum import Enum > class Color(Enum): > red = 1 > blue = 2 > green = 3 > >>>> Color(Color.red.value+1) > <Color.blue: 2>
But: >>> class Color(enum.Enum): ... red = 0xff0000 ... green = 0x00ff00 ... blue = 0x0000ff ... >>> Color(Color.red.value + 1) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.4/enum.py", line 222, in __call__ return cls.__new__(cls, value) File "/usr/lib64/python3.4/enum.py", line 457, in __new__ raise ValueError("%r is not a valid %s" % (value, cls.__name__)) ValueError: 16711681 is not a valid Color I take it that enums in Python are identifiers only. While you can iterate over all enums (and the definition order is preserved), it is simply a way to operate on *all* enums. So the answer to the OP's question is: that feature is not supported. Marko -- https://mail.python.org/mailman/listinfo/python-list