[Python-Dev] Pickling of Enums
storchaka at gmail.com
Tue Feb 18 20:46:27 CET 2014
18.02.14 20:16, Ethan Furman написав(ла):
> This conversation wasn't in the PEP, but as I recall we decided to go
> with value instead of name for json because the receiving end may not be
> running Python.
> Is having json do it one way and pickle another a problem?
We decided to go with value instead of name for JSON because JSON
doesn't support enums, but supports integers and strings, and because
enums are comparable with they values, but not with they names.
>>> json.loads(json.dumps(socket.AF_INET)) == socket.AF_INET
We simply had no other choice.
More information about the Python-Dev