[Python-Dev] enum discussion: can someone please summarize open issues?
Eli Bendersky
eliben at gmail.com
Thu May 2 18:00:35 CEST 2013
On Thu, May 2, 2013 at 8:57 AM, Barry Warsaw <barry at python.org> wrote:
> On May 02, 2013, at 08:42 AM, Larry Hastings wrote:
>
> >So, for the second time: How can Color.red and MoreColor.red be the same
> >object when they are of different types?
>
> It's a moot point now given Guido's pronouncement.
>
Correct. There's no Color.red and MoreColor.red. Subclassing is allowed
only of enums that define no members. So this is forbidden:
>>> class MoreColor(Color):
... pink = 17
...
TypeError: Cannot subclass enumerations
But this is allowed:
>>> class Foo(Enum):
... def some_behavior(self):
... pass
...
>>> class Bar(Foo):
... happy = 1
... sad = 2
...
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130502/f1c552b7/attachment.html>
More information about the Python-Dev
mailing list