[Python-ideas] PEP XXX - Competitor with PEP 435: Adding an enum type to the Python standard library
eliben at gmail.com
Tue Mar 12 18:28:43 CET 2013
On Tue, Mar 12, 2013 at 9:59 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
> On Mar 12, 2013, at 8:36, Eli Bendersky <eliben at gmail.com> wrote:
> > It is actually better, because it emphasizes that NamedInt is just that,
> not a kind of Enum. There's just one enum. Moreover, I'm not sure why
> strings need to be named (they name themselves just fine). And moreover+,
> Bitmask IMHO is completely unnecessary in Python.
> It's necessary everywhere we interface with C APIs and binary formats that
> use them. Even the stdlib is full of candidates--the flags in os, stat,
> etc. are all bitmasks.
I think that viewing the Python programmer community at large, very few
actually interact with C APIs that have bitmasked flags. Moreover, a
NamedInt can fit the bill without needing a specific bitmask flag.
If you have "names" for your flag constituents you can just join them with
'|' as in C. This is similar to what's currently being done in modules like
os and stat, but provides conveniently printable names for the magic
numbers. The benefits of a specific bitmasking class in the stdlib are imho
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas