A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-May/125869.html below:

[Python-Dev] Enum: subclassing?

[Python-Dev] Enum: subclassing? [Python-Dev] Enum: subclassing?Barry Warsaw barry at python.org
Thu May 2 17:23:56 CEST 2013
On May 01, 2013, at 08:47 PM, Georg Brandl wrote:

>Wait a moment... it might not be immediately useful for IntEnums (however,
>that's because base Enum currently defines __int__ which I find questionable),

And broken.  And unnecessary. :)

>>> class Foo(Enum):
...   a = 'a'
...   b = 'b'
... 
>>> int(Foo.a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __int__ returned non-int (type str)


...remove Enum.__int__()...

>>> class Bar(int, Enum):
...   a = 1
...   b = 2
... 
>>> int(Bar.a)
1


So yes, Enum.__int__() should be removed.

-Barry
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4