[Python-Dev] PEP 435: initial values must be specified? Yes
Tim Delaney
timothy.c.delaney at gmail.com
Mon May 6 01:14:36 CEST 2013
More information about the Python-Dev mailing list
Mon May 6 01:14:36 CEST 2013
- Previous message: [Python-Dev] PEP 435: initial values must be specified? Yes
- Next message: [Python-Dev] PEP 435: initial values must be specified? Yes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6 May 2013 08:55, Eli Bendersky <eliben at gmail.com> wrote: > 1. That the dictionary returned from <enum metaclass>.__prepare__ provide > a way to obtain the enum instance names once it's been populated (e.g. once > it's been passed as the classdict to __new__). The reference implementation > provides a _enum_names list attribute. The enum names need to be available > to a metaclass subclass before calling the base metaclass __new__. > >> So your preferred solution is (1), which requires exposing the metaclass >> and an attribute publicly? I have to ask - to what end? What is the goal of >> this? To have an AutoNumberedEnum which is guaranteed to be compatible with >> stdlib's Enum? >> > My preferred solution is 1 (for the reason mentioned above) but it does not require exposing the metaclass publically (that's obtainable via type(Enum)). It does require a way to get the enum names before calling the base metaclass __new__, but that does not necessarily imply that I'm advocating exposing _enum_names (or at least, not directly). My preferred way would probably be a note that the dictionary returned from the enum metaclass __prepare__ implements an enum_names() or maybe __enum_names__() method which returns an iterator over the enum instance names in definition order. The way this is implemented by the dictionary would be an implementation detail. The enum metaclass __new__ needs access to the enum instance names in definition order, so I think making it easily available to enum metaclass subclasses as well just makes sense. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130506/65589332/attachment.html>
- Previous message: [Python-Dev] PEP 435: initial values must be specified? Yes
- Next message: [Python-Dev] PEP 435: initial values must be specified? Yes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list