[Python-Dev] PEP 435 - requesting pronouncement (original) (raw)
Charles-François Natali cf.natali at gmail.com
Sun May 5 19:07:55 CEST 2013
- Previous message: [Python-Dev] PEP 435 - requesting pronouncement
- Next message: [Python-Dev] PEP 435 - requesting pronouncement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm chiming in late, but am I the only one who's really bothered by the syntax?
class Color(Enum): red = 1 green = 2 blue = 3
I really don't see why one has to provide values, since an enum constant is the value. In many cases, there's no natural mapping between an enum constant and a value, e.g. there's no reason why Color.red should be mapped to 1 and Color.blue to 3.
Furthermore, the PEP makes it to possible to do something like:
class Color(Enum): red = 1 green = 2 blue = 3 red_alias = 1
which is IMO really confusing, since enum instances are supposed to be distinct.
All the languages I can think of that support explicit values (Java being particular in the sense that it's really a full-fledge object which can have attributes, methods, etc) make it optional by default.
Finally, I think 99% of users won't care about the assigned value (which is just an implementation detail), so explicit value will be just noise annoying users (well, me at least :-).
cf
2013/5/5 Eli Bendersky <eliben at gmail.com>:
Hello pydev,
PEP 435 is ready for final review. A lot of the feedback from the last few weeks of discussions has been incorporated. Naturally, not everything could go in because some minor (mostly preference-based) issues did not reach a consensus. We do feel, however, that the end result is better than in the beginning and that Python can finally have a useful enumeration type in the standard library. I'm attaching the latest version of the PEP for convenience. If you've read previous versions, the easiest way to get acquainted with the recent changes is to go through the revision log at http://hg.python.org/peps A reference implementation for PEP 435 is available at https://bitbucket.org/stoneleaf/ref435 Kind regards and happy weekend.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/cf.natali%40gmail.com
- Previous message: [Python-Dev] PEP 435 - requesting pronouncement
- Next message: [Python-Dev] PEP 435 - requesting pronouncement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]