[Python-ideas] Decorator for creating enumeration?
kirillbalunov at gmail.com
Sun Dec 10 05:23:59 EST 2017
Since PEP 557 "Data Classes" and PEP 526 "Syntax for Variable
Annotations" are accepted and become part of the language. Is it worth
writing a proposal about decorator-version for creating an enumeration?
from enum import enum
@enum(unique=True, int_=False, flag=False, ...):
RED : auto
BLUE : auto
Despite the fact that Functional API to create enums already exists, it
seems to me that decorator-version will allow to unify these two relatively
young residents of the standard library. In addition, the idea of "Not
having to specify values for enums", which at the time seemed to involve
much magic in the implementation, becomes part of the language. Of course,
PEP 526 unequivocally says that it does not allow one to annotate the types
of variables when tuple unpacking is used. But in any case, I find the
variant with the decorator to be an interersting idea.
With kind regards, -gdg
 PEP 557 "Data Classes" <https://www.python.org/dev/peps/pep-0557/>
 PEP 526 "Syntax for Variable Annotations"
 Not having to specify values for enums.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas