[Python-Dev] PEP 435 - requesting pronouncement
Paul Moore
p.f.moore at gmail.com
Sun May 5 19:41:59 CEST 2013
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:
1. 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.
2. 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.
3. 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.
4. 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>
More information about the Python-Dev
mailing list