Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13200

Re: What do you guys think about adding a method "to_json"

From Terry Reedy <tjreedy@udel.edu>
Subject Re: What do you guys think about adding a method "to_json"
Date 2011-09-12 17:04 -0400
References <CAHowWJkzOr30FU1XDZ74rD1qJxYxteT+q2TbD9E4GZ+Js7dA7g@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1049.1315861509.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What do you guys think about adding a method "to_json" Terry Reedy <tjreedy@udel.edu> - 2011-09-12 17:04 -0400

csiph-web