[Python-Dev] constant/enum type in stdlib

P.J. Eby pje at telecommunity.com
Tue Nov 23 17:52:37 CET 2010


At 11:31 AM 11/23/2010 -0500, Barry Warsaw wrote:
>On Nov 23, 2010, at 03:15 PM, Michael Foord wrote:
>
> >(Well, there is a third option that takes __name__ and sets the constants in
> >the module automagically. I can understand why people would dislike that
> >though.)
>
>Personally, I think if you want that, then the explicit class definition is a
>better way to go.

This reminds me: a stdlib enum should support proper pickling and 
copying; i.e.:

    assert SomeEnum.anEnum is pickle.loads(pickle.dumps(SomeEnum.anEnum))

This could probably be implemented by adding something like:

    def __reduce__(self):
        return getattr, (self._class, self._enumname)

in the EnumValue class.



More information about the Python-Dev mailing list