On 05/06/2013 10:18 PM, Tim Delaney wrote: > On 7 May 2013 15:14, Tim Delaney <timothy.c.delaney at gmail.com <mailto:timothy.c.delaney at gmail.com>> wrote: > > Unfortunately, if you subclass AutoNumber from IntEnum it breaks. > > ---------- Run Python3 ---------- > Traceback (most recent call last): > File "D:\home\repos\mercurial\ref435\ref435.py", line 346, in <module> > class Color(AutoNumber): > File "D:\home\repos\mercurial\ref435\ref435.py", line 184, in __new__ > enum_item = __new__(enum_class, *args) > TypeError: int() argument must be a string or a number, not 'ellipsis' > > > Or using your exact implementation, but subclassing AutoNumber from IntEnum: > > class AutoNumber(IntEnum): > def __new__(cls): > value = len(cls.__enum_info__) + 1 > obj = object.__new__(cls) > obj._value = value > return obj > def __int__(self): > return self._value > class Color(AutoNumber): > red = () > green = () > blue = () > > print(repr(Color.red)) > > ---------- Run Python3 ---------- > <Color.red: ()> Thanks for the test case. It now passes. -- ~Ethan~
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