[docs] json module documentation error

Todd DeLuca todddeluca at gmail.com
Tue Apr 12 04:29:25 CEST 2011


Hi,

The 2.7 docs for the json module online (
http://docs.python.org/library/json.html) say:

If *indent* is a non-negative integer, then JSON array elements and object
members will be pretty-printed with that indent level. An indent level of 0
will only insert newlines. None (the default) selects the most compact
representation.
I believe it should read, "An indent level of less than zero will only
insert newlines."  Some example output follows:

>>> sys.version_info
sys.version_info(major=2, minor=7, micro=0, releaselevel='final', serial=0)
>>> print json.dumps((1,(2,3)), indent=0)
[1, [2, 3]]
>>> print json.dumps((1,(2,3)), indent=1)
[
 1,
 [
  2,
  3
 ]
]
>>> print json.dumps((1,(2,3)), indent=-2)
[
1,
[
2,
3
]
]

Have a great day and thanks for all your hard work and for the best
programming language docs on the internet!

-- 
Todd DeLuca
http://todddeluca.com
27 Clinton St #2
Cambridge MA 02139

Scientific Programmer
Wall Laboratory for Translational Bioinformatics
Center For Biomedical Informatics at Harvard Medical School
http://wall.hms.harvard.edu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110411/e5c2ed24/attachment.html>


More information about the docs mailing list