[Python-Dev] PEP 435 - reference implementation discussion
Ethan Furman
ethan at stoneleaf.us
Sun May 5 08:17:19 CEST 2013
More information about the Python-Dev mailing list
Sun May 5 08:17:19 CEST 2013
- Previous message: [Python-Dev] PEP 435 - reference implementation discussion
- Next message: [Python-Dev] PEP 435 - reference implementation discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 05/04/2013 10:59 PM, Ethan Furman wrote: > On 05/04/2013 08:50 PM, Tim Delaney wrote: >> >> Think I've come up with a system that works for my auto-numbering case without knowing the internals of enum_type. Patch >> passes all existing test cases. The patch does two things: >> [snip] >> 2. Instead of directly setting the _name and _value of the enum_item, it lets the Enum class do it via Enum.__init__(). >> Subclasses can override this. This gives Enums a 2-phase construction just like other classes. > > Not sure I care for this. Enums are, at least in theory, immutable objects, and immutable objects don't call __init__. Okay, still thinking about `value`, but as far as `name` goes, it should not be passed -- it must be the same as it was in the class definition or we could end up with something like: --> class AreYouKiddingMe(WierdEnum): ... who = 1 ... what = 2 ... when = 3 ... where = 4 ... why = 5 --> list(AreYouKiddingMe) [ <AreYouKiddingMe.him: 1>, <AreYouKiddingMe.that: 2>, <AreYouKiddingMe.now: 3>, <AreYouKiddingMe.here: 4>, <AreYouKiddingMe.because: 5>, ] and that's assuming we made more changes to support such insane behavior; otherwise it would just break. So no passing of `name`, it gets set in the metaclass. -- ~Ethan~
- Previous message: [Python-Dev] PEP 435 - reference implementation discussion
- Next message: [Python-Dev] PEP 435 - reference implementation discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list