[Python-Dev] Enum: subclassing?
Eli Bendersky
eliben at gmail.com
Wed May 1 23:57:33 CEST 2013
More information about the Python-Dev mailing list
Wed May 1 23:57:33 CEST 2013
- Previous message: [Python-Dev] Enum: subclassing?
- Next message: [Python-Dev] Enum: subclassing?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, May 1, 2013 at 2:52 PM, Georg Brandl <g.brandl at gmx.net> wrote: > Am 01.05.2013 23:48, schrieb Eli Bendersky: > > > Well, my point is that you currently don't have to inherit from int > (or IntEnum) > > to get an __int__ method on your Enum, which is what I find > questionable. IMO > > conversion to integers should only be defined for IntEnums. (But I > haven't > > followed all of the discussion and this may already have been > decided.) > > > > > > Good point. I think this may be just an artifact of the implementation - > PEP 435 > > prohibits implicit conversion to integers for non-IntEnum enums. Since > IntEnum > > came into existence, there's no real need for int-opearbility of other > enums, > > and their values can be arbitrary anyway. > > OK, I'm stupid -- I was thinking about moving the __int__ method to IntEnum > (that's why I brought it up in this part of the thread), but as a subclass > of > int itself that obviously isn't needed :) You did bring up a good point, though - __int__ should not be part of vanilla Enum. Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130501/15281b38/attachment.html>
- Previous message: [Python-Dev] Enum: subclassing?
- Next message: [Python-Dev] Enum: subclassing?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list