Re: [Python-Dev] Pickling of Enums

2014年2月18日 11:49:40 -0800

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
True
We simply had no other choice.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to