What do you guys think about adding a method "to_json"
Terry Reedy
tjreedy at udel.edu
Mon Sep 12 17:04:50 EDT 2011
On 9/12/2011 12:34 AM, Juan Pablo Romero Méndez wrote:
> Hello,
>
> What do you guys think about adding a method "to_json" to dictionaries
> and sequence types? Perhaps through a module import?
Negative. If this were added, why not to_yaml, to_marshal, to_pickle,
to_zip, and so on. Better to have each storage or transfer class handle
its own instance creation. The one to_x method that every class should
have is to_string, which is spelled __str__ and inherited from object.
--
Terry Jan Reedy
More information about the Python-list
mailing list