On Sat, 23 Feb 2013 08:27:50 -0800, Eli Bendersky <eli...@gmail.com> wrote: > On Sat, Feb 23, 2013 at 7:57 AM, R. David Murray <rdmur...@bitdance.com>wrote: > > > On Sun, 24 Feb 2013 01:31:09 +1000, Nick Coghlan <ncogh...@gmail.com> > > wrote: > > > On Sun, Feb 24, 2013 at 1:06 AM, Antoine Pitrou <solip...@pitrou.net> > > wrote: > > > > On Sat, 23 Feb 2013 16:02:31 +0100 > > > > Stefan Krah <ste...@bytereef.org> wrote: > > > >> eli.bendersky <python-check...@python.org> wrote: > > > >> > +Ordered comparisons between enumeration values are *not* > > supported. Enums are > > > >> > +not integers! > > > >> > > > >> Hmm. I think this limits interoperation with C libraries and > > prototyping > > > >> C code. > > > > > > > > Agreed, this is a deal-breaker IMO. I'd actually argue that enums are > > > > not terribly useful apart from interacting with C constants. > > > > > > I've argued in the past that we should have a "Named Value" mechanism > > > *before* we have a proposal to group named constants in some fashion > > > (such as sequential enums, or binary flag groups). It never gained > > > much traction, even though it could be more useful in many cases > > > (think things like being able to tag a file descriptor with the repr > > > of the object it belongs to) > > > > > > After seeing this checkin, I also suggested to Eli and Barry that any > > > new PEP on this topic should come with a survey of *existing* > > > pseudo-enums in the standard library, and an explanation of how the > > > proposal can be used to make those either easier to debug when they > > > show up in error messages or otherwise make it easier to detect when > > > you've made a mistake while working with them. > > > > See also http://bugs.python.org/issue16801#msg178542 for another use > > case for named values. > > > > I've seen an awful lot of code that uses global variables or class > > attributes primarily to get name validation on constant values, and I > > think all of that code would be a prime candidate for using Named Values. > > Some of them are also enum-like, but many of them are not. So I'm with > > Nick on this one. > > > > Any suggestions for places in the stdlib where enums could come useful will > be most welcome
Heh. I wasn't actually speaking about the stdlib in the second paragraph :) But, if we had a Named Value facility I would use it in the email library for header error sub-codes (something I haven't actually introduced yet). But, speaking of error codes, it would be really nice if the posix error numbers had a repr that included the name. --David _______________________________________________ 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