[issue17959] Alternate approach to aliasing for PEP 435
Ethan Furman
report at bugs.python.org
Sun May 12 12:44:26 CEST 2013
Ethan Furman added the comment:
Another approach to handling this, and other, issues is to allow options to EnumMeta. My original aenum code had the default Enum class as unordered, no duplicates allowed, non-indexable, etc., but then allowed options to be passed in such as DUPLICATES to allow duplicates, ORDERED to add the ge-gt-le-lt methods, INDEXED to add __index__, etc.
For the aliasing issue this method is more robust as placeholders are not required, and code like this will work:
class Physics(Enum):
e = 2.81847
pi = 3.141596
tau = 2 * pi
To make that code work with placeholders is possible (I have it in aenum) but a major pain (I was about to remove it before my offer to help with ref435 was accepted).
----------
nosy: +ethan.furman
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17959>
_______________________________________
More information about the Python-bugs-list
mailing list