What do you guys think about adding a method "to_json"
tjreedy at udel.edu
Mon Sep 12 23:04:50 CEST 2011
On 9/12/2011 12:34 AM, Juan Pablo Romero Méndez wrote:
> 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