[Python-ideas] pprint in displayhook

Antoine Pitrou solipsis at pitrou.net
Fri Sep 27 15:05:50 CEST 2013


Le Fri, 27 Sep 2013 08:47:42 -0400,
"Eric V. Smith" <eric at trueblade.com> a écrit :
> On 9/27/2013 8:40 AM, Nick Coghlan wrote:
> > 
> > On 27 Sep 2013 21:58, "Antoine Pitrou" <solipsis at pitrou.net
> > <mailto:solipsis at pitrou.net>> wrote:
> >>
> >> Le Fri, 27 Sep 2013 14:15:13 +0300,
> >> Serhiy Storchaka <storchaka at gmail.com
> >> <mailto:storchaka at gmail.com>> a écrit :
> >> > 27.09.13 13:15, Antoine Pitrou написав(ла):
> >> > > Le Fri, 27 Sep 2013 13:07:18 +0300,
> >> > > Serhiy Storchaka <storchaka at gmail.com
> >> > > <mailto:storchaka at gmail.com>> a écrit :
> >> > >> What are you think about using pprint.pprint() to output the
> >> > >> result of evaluating an expression entered in an interactive
> >> > >> Python session (and in IDLE)?
> >> > >
> >> > > I'm not sure I like this idea.  AFAICT pprint() isn't
> >> > > bullet-proof, and it would be a pain to debug if it failed to
> >> > > display some objects properly.
> >> >
> >> > We can set displayhook in site.py and for debug restore it from
> >> > sys.__displayhook__. This is not more painful than use readline
> >> > and enable completion by default.
> >>
> >> :-) I don't know, I'll let other people experiment with it.
> > 
> > displayhook uses repr by default. Even normal print would make
> > numbers and numeric string output ambiguous.
> 
> Wouldn't this also invalidate the millions (I'm guessing) of examples
> in blogs, how-tos, etc. that show interactive command line examples?
> I'm sympathetic, but I don't think it's worth it.

Oh and how about... doctest? :-)





More information about the Python-ideas mailing list