[Python-ideas] Enum and serialization

Giampaolo Rodola' g.rodola at gmail.com
Thu Jul 18 20:13:46 CEST 2013


I just received this bug report in psutil:
https://code.google.com/p/psutil/issues/detail?id=408

Long story short, in psutil I have defined a constant type:
http://code.activestate.com/recipes/577984-named-constant-type/
https://code.google.com/p/psutil/source/browse/psutil/_common.py#31
...behaving along these lines:

>>> FOO = constant(0, 'FOO')
>>> FOO
0
>>> str(FOO)
'FOO'

It's a nasty problem and I'm still not sure how to solve it in psutil
but this got me thinking about PEP 435 (Adding an Enum type to the
Python standard library) since the two things are kind of related.
I haven't properly gone through the PEP yet (I will) but I notice it
doesn't talk about serialization.
Has it been considered?

Regards,

- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/


More information about the Python-ideas mailing list