On 04/26/2013 11:17 AM, Eli Bendersky wrote:
I feel that this thread has lost track of it long ago. Some time back in the
Enum discussions (some 350 messages ago or
so), there was a proposal to have this:
class Color(Enum):
RED, BLUE, GREEN
By doing some crazy-cool shenanigans. Although the syntax is great, it was
rejected on the basis of being too magic.
Although explicit reasons were not mentioned (and perhaps not even consciously recognized -- *sigh* someday I hope to be
that good),
there are very good ones beyond "being too magic" -- way too easy to introduce bugs: name lookup success looks exactly
like name lookup failure, but the consequences were drastically different:
class Color(Enum):
BLACK
RED
GREEN
BLUE
class MoreColor(Enum):
BLACK
CYAN
MAGENTA
YELLOW
BLACK in MoreColor is a bug that cannot easily be detected as it is a successful name lookup; the consequence is that
CYAN, MAGENTA, and YELLOW are now off by one.
Not being Dutch, I had to smack into that one before I gave up on the idea.
--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com