[Python-Dev] constant/enum type in stdlib

Barry Warsaw barry at python.org
Tue Nov 23 21:01:02 CET 2010


On Nov 23, 2010, at 11:52 AM, P.J. Eby wrote:

>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.

Excellent idea, thanks.  Added to flufl.enum in r38.  However, only enums
created with the class syntax can be pickled though.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101123/4ebdef12/attachment.pgp>


More information about the Python-Dev mailing list