[Python-Dev] PEP 435: initial values must be specified? Yes (original) (raw)

Ethan Furman ethan at stoneleaf.us
Tue May 7 11:49:47 CEST 2013


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 class Color(AutoNumber): File "D:\home\repos\mercurial\ref435\ref435.py", line 184, in new enumitem = new(enumclass, *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.enuminfo) + 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



More information about the Python-Dev mailing list