Guido van Rossum added the comment:

The proposal to change json from using repr() to str() has unknown dangers.

I don't want the str() of IntEnum to return just the decimal string (e.g. 
"42"), since that breaks half of the usefulness of using the enum in the first 
place -- people will write print(x) and be confused.

Unfortunately the json module doesn't have a way to define *in the object* how 
to customize its serialization -- this is always done in the json 
encoder/decoder.  Maybe we can add something to the JSON encoder and decoder 
class that looks for a special method, e.g. __json_encode__ etc.?  (OR maybe 
this would be a use case for PEP 443?)

----------
nosy: +gvanrossum

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18264>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to