March 2003
Intermediate to advanced
656 pages
39h 30m
English
pprint
pprint(obj,stream=sys.stdout)
Outputs the pretty-printing of obj to file
object stream, with a terminating newline.
The following statements are the same:
print pprint.pformat(x) pprint.pprint(x)
Either of these constructs will be roughly the same as
print
x in many cases,
such as when the string representation of
x fits within one line. However, with
something like
x
=range(30),
print
x displays
x in two lines, breaking at an arbitrary point,
while using module pprint displays
x over 30 lines, one line per item. You can use
module pprint when you prefer the
module’s specific display effects to the ones of
normal string representation.
Read now
Unlock full access