Am I the only one who would love these extentions? - Python 3.0proposals (long)

Dave Brueck dave at pythonapocrypha.com
Wed Nov 12 12:37:40 EST 2003


> I like some of your suggestions, like enum.

I wouldn't mind having a standard module include something like this:

class Enumerate(object):
    def __init__(self, names):
        for number, name in enumerate(names.split()):
            setattr(self, name, number)

WORK = Enumerate('NONE WRITE READ SENDFILE CONNECT ACCEPT')

I like it better than C-style enums because it's clear that the element
comes from a particular enumeration, e.g.:

workFlags = WORK.WRITE

-Dave






More information about the Python-list mailing list