Ethan Furman writes:

 > Enumerations can be pickled and unpickled::
 > 
 >      >>> from enum import Enum
 >      >>> class Fruit(Enum):
 >      ...     tomato = 1
 >      ...     banana = 2
 >      ...     cherry = 3
 >      ...
 >      >>> from pickle import dumps, loads
 >      >>> Fruit.tomato is loads(dumps(Fruit.tomato))
 >      True
 > [...]
 > Still, it would be nice if this could work.

Well, you could cheat and reverse the test. ;-)

I assume the problem is that loads proceeds to recreate the Fruit
enum, rather than checking if there already is one?  Maybe the
metaclass can check somehow?  At the very least, if this can't work in
this implementation, unpickling should be an error.

_______________________________________________
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

Reply via email to