[issue19040] Problems with overriding Enum.__new__

2013-09-27 Thread Ethan Furman
Changes by Ethan Furman : -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker ___ ___

[issue19040] Problems with overriding Enum.__new__

2013-09-24 Thread Ethan Furman
Ethan Furman added the comment: Doc patch is in #19011. I'll close this one when that one is closed. -- ___ Python tracker ___ ___ Py

[issue19040] Problems with overriding Enum.__new__

2013-09-23 Thread Eli Bendersky
Eli Bendersky added the comment: On Sun, Sep 22, 2013 at 9:04 PM, Ethan Furman wrote: > > Ethan Furman added the comment: > > Yup, just trying to add some explanation on how it currently works. > > Drekin, I'm sure you've already figured this out, but for those who may > read this in the future:

[issue19040] Problems with overriding Enum.__new__

2013-09-23 Thread Drekin
Drekin added the comment: Yes, I've done it similarily using a class method. Thank you for help. -- ___ Python tracker ___ ___ Python-

[issue19040] Problems with overriding Enum.__new__

2013-09-22 Thread Ethan Furman
Ethan Furman added the comment: Yup, just trying to add some explanation on how it currently works. Drekin, I'm sure you've already figured this out, but for those who may read this in the future: what you need is a helper function: def OptionalEnum(value): "could also be OptionalEnum(enu

[issue19040] Problems with overriding Enum.__new__

2013-09-22 Thread Eli Bendersky
Eli Bendersky added the comment: LGTM, Ethan. You know how I feel about customization in general ;-) We should give Enum a term or two in the stdlib to learn how it's being used and abused - we can always *add* customization in the future. -- ___ Py

[issue19040] Problems with overriding Enum.__new__

2013-09-22 Thread Ethan Furman
Ethan Furman added the comment: How about this note after the AutoNumber example? .. note:: The :meth:`__new__` method, if defined, is used during creation of the Enum members; it is then replaced by Enum's :meth:`__new__` which is used after class creation for lookup of existing me

[issue19040] Problems with overriding Enum.__new__

2013-09-17 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue19040] Problems with overriding Enum.__new__

2013-09-17 Thread Drekin
New submission from Drekin: I tried to implement an Enum variant OptionalEnum such that OptionalEnum(value) leaves value alone and returnes it (if there is no corresponding enum member) rather than raising ValueError. My use case is following: I'm trying to parse some keyboard layout related d