New submission from Gerrit Holl: The OO API allows to create empty enums, i.e. without any values. However, the functional API does not, as this will result in an IndexError as shown below:
In [1]: import enum In [2]: class X(enum.IntFlag): pass In [3]: Y = enum.IntFlag("Y", []) --------------------------------------------------------------------------- IndexError Traceback (most recent call last) <ipython-input-3-1fda5945e0b2> in <module>() ----> 1 Y = enum.IntFlag("Y", []) ~/lib/python3.6/enum.py in __call__(cls, value, names, module, qualname, type, start) 291 return cls.__new__(cls, value) 292 # otherwise, functional API: we're creating a new Enum type --> 293 return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start) 294 295 def __contains__(cls, member): ~/lib/python3.6/enum.py in _create_(cls, class_name, names, module, qualname, type, start) 382 if isinstance(names, str): 383 names = names.replace(',', ' ').split() --> 384 if isinstance(names, (tuple, list)) and isinstance(names[0], str): 385 original_names, names = names, [] 386 last_values = [] IndexError: list index out of range ---------- messages: 295559 nosy: Gerrit.Holl priority: normal severity: normal status: open title: Cannot use functional API to create enum with zero values versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30616> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com