Raymond Hettinger added the comment:
Temporarily, marking this as open so that more people can see the new comments.
For John, I'm not sure what I can say that will help you. The goal of the
standard libraries modules is to provide tools the use language we have, not to
invent a new language the isn't really Python or Pythonic. In the absence of
an "enum" keyword, you have a number of ways to work within the language.
In this case (wanting auto numbering but not caring what the values are), you
already have several ways to do it. I your issue is not where the use case is
met; instead, you just don't like how their spelled (because it isn't exactly
how it it looks in C).
This already works: Animal = Enum('Animal', ['ant', 'bee', 'cat', 'dog']).
This is very flexible and lets you read the constants from many possible
sources.
If you're attracted to multiline input, that is already possible as well:
Animal = Enum('Animal', '''
ant
bee
cat
dog
''')
It is clear that you're bugged by writing Animal twice, but that is how Python
normally works and it is a very minor nuisance (it only occurs once when the
enum is defined). Note, you already are rewriting "Animal" every time you use
the enum value (presumably many times): board_ark(Animal.ant, Animal.bee)
This whole feature request boils down to wanting a currently existing feature
to be spelled a little differently, in a way that doesn't look like normal
Python. Elsewhere, we resisted the temptation to alter the language
look-and-feel to accommodate small spelling tweaks for various modules (i.e. we
pass in normal strings to the regex module even though that sometimes requires
double escaping, we pass in the class name to namedtuples even though that uses
the class name twice, the xpath notation in passed into XML tools as strings
even though parts of it look like regular langauge, we don't abuse the |
operator to link together chains of itertools, etc)
Since the enum module already provides one way to do it, I recommend that we
stick with that one way. Creating too many variants does not help users.
Using the core language in odd ways also does not help users.
----------
status: closed -> open
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com