[Python-Dev] PEP 435 - requesting pronouncement (original) (raw)
Paul Moore p.f.moore at gmail.com
Sun May 5 19:41:59 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 ]
OK, I thought I'd take a look. I have never particularly needed enums in real life, so I'm reading the PEP from the POV of a naive user who is just thinking "hey, neat, Python got enums, let's see how they work". I have been skimming the discussions and my head has been exploding with the complexity, so I admit I was very, very scared that the PEP might be equally daunting.
First, the good news - from the POV described above, the PEP is both readable and intuitive. Nice job, guys!
Now the problems I had:
- Having to enter the values is annoying. Sorry, I read the rationale and all that, and I still want to write a C-Like enum { A, B, C }. I fully expect to edit and reorder enums (if I ever use them) and get irritated with having to update the value assignments.
- Enums are not orderable by default. Yuk. I doubt I'll care about this often (iteration is more important) but when I do, I'll be annoyed.
- This is just a thought, but I suspect that IntEnums iterating in definition order but ordering by value could trip people up and cause hard to diagnose bugs.
- I'll either use the functional form all the time (because I don't have to specify values) or never (because it's ugly as sin). I can't work out which aspect will win yet.
And one omission that struck me. There's no mention of the common case of bitmap enums.
class Example(Enum): a = 1 b = 2 c = 4
Do I need to use an IntEnum (given the various warnings in the PEP about how "most people won't need it") if I want to be able to do things like flags = "Example.a | Example.c"? I think there should at least be an extended example in the PEP covering a bitmap enum case. (And certainly the final documentation should include a cookbook-style example of bitmap enums).
Summary - good job, I like the PEP a lot. But Python's enums are very unlike those of other languages, and I suspect that's going to be more of an issue than you'd hope...
Paul.
On 4 May 2013 23:04, Eli Bendersky <eliben at gmail.com> wrote:
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/p.f.moore%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130505/b8f6af66/attachment.html>
- Previous message: [Python-Dev] PEP 435 - requesting pronouncement
- Next message: [Python-Dev] PEP 435 - requesting pronouncement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]