Vedran Čačić added the comment:

> For me, it's legit to use a singleton in an enum.

But you cannot explain _why_, right? Like Raymond says, it's not working like 
anything else in Python works.

To me, this looks almost the same as the gripes of those lazy people who want 
"myfile.close" expression to close myfile, or worse, "quit" to exit the Python 
interpreter. An irrational phobia of parentheses. Why not call your object, if 
you expect some code to be executed? [At least a dotted name like myfile.close 
_could_ be made to work using descriptors, but still I think everyone agrees 
it's not a good idea.]

To me, we either want to stay with default type metaclass 
(`style='imperative'`:), and write something like

    class Color(Enum):
        green = member()
        yellow = member()

or we acknowledge that `style='declarative'` has its place under the sun (not 
only for Enums, of course... database models, namedtuples, even ABCs could 
profit from it), and embrace its full power, realizing it's not Python we 
usually see, but it's still Python.

Magic is not something to be afraid of, if you understand it. We are talking 
Py3.6 here... aren't formatted strings a totally insane magic? Yet they ended 
up in the language, because they are immensely better than the alternatives. 
Here the gain is much smaller, but the threshold is much lower too: we don't 
need new syntax at all.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to