On 05/06/2013 10:18 PM, Tim Delaney wrote:
On 7 May 2013 15:14, Tim Delaney <[email protected] <mailto:[email protected]>> 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~ _______________________________________________ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
