<div dir="ltr">There's a third-party enum package. Maybe you can contribute an implementation of this idea there. If it becomes popular maybe we can add it to the stdlib enum module.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 10, 2017 at 2:23 AM, Kirill Balunov <span dir="ltr"><<a href="mailto:kirillbalunov@gmail.com" target="_blank">kirillbalunov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px">Since PEP 557 "Data Classes"[1] and PEP 526 "Syntax for Variable Annotations"[2] are accepted and become part of the language. Is it worth writing a proposal about decorator-version for creating an enumeration? Something like:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">from enum import enum</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">@enum(unique=True, int_=False, flag=False, ...):</div><div style="font-size:12.8px">class Color:</div><div style="font-size:12.8px">    RED     : auto</div><div style="font-size:12.8px">    GREEN: auto</div><div style="font-size:12.8px">    BLUE    : auto</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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"[3], 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.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">With kind regards, -gdg</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">[1]  <a href="https://www.python.org/dev/peps/pep-0557/" target="_blank">PEP 557 "Data Classes"</a></div><div style="font-size:12.8px">[2]  <a href="https://www.python.org/dev/peps/pep-0526/" target="_blank">PEP 526 "Syntax for Variable Annotations"</a></div><div style="font-size:12.8px">[3] <a href="https://www.python.org/dev/peps/pep-0435/#not-having-to-specify-values-for-enums" target="_blank"> <span style="font-size:12.8px">Not having to specify values for enums.</span></a></div></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>