[Python-bugs-list] [ python-Bugs-505152 ] pprint should (optionally) use str

noreply@sourceforge.net noreply@sourceforge.net
Mon, 01 Apr 2002 21:15:45 -0800


Bugs item #505152, was opened at 2002-01-17 18:15
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505152&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: Barry Warsaw (bwarsaw)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: pprint should (optionally) use str

Initial Comment:
pprint.pprint() uses repr to display an object. 
However I think it's at least as likely that pretty
printing would be used as a human debugging tool rather
than for generating a string "which can be used as
input to the interpreter".

pprint.pprint() -- and PrettyPrinter.pprint() should
optionally use str() to print a human readable
representation of the object.


----------------------------------------------------------------------

>Comment By: Barry Warsaw (bwarsaw)
Date: 2002-04-02 00:15

Message:
Logged In: YES 
user_id=12800

I'll make two points.  First, the pprint module
documentation should clearly state that repr() is used
instead of str().  It seems vague to me.

Second, perhaps we should add a pprint.sprint() to use str()
instead of repr().  I don't think the class needs to be
derivable, since other than str and repr, I can't think of
what you'd want to pretty print about an object. :)

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-04-02 00:08

Message:
Logged In: YES 
user_id=3066

The usefulness of str() seems questionable; if the issue is
debugging, repr()-like presentation seems to make more
sense.  I do think the pretty-printer should be configurable
(via subclassing at least).

I've checked in an attempt to make it easier to change the
machinery use, but I'm not sure this is really the right change.

I'm closing the bug report as vague, but am interested in
suggestions for improving the pprint module.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505152&group_id=5470