[Python-Dev] Re: [Python-checkins] python/dist/src/Lib pprint.py, 1.24, 1.25

Gerrit Holl gerrit@nl.linux.org
Sun, 8 Jun 2003 11:37:11 +0200


Hello,

Since my last post here is >3 years old, I'll introduce myself: I am
Gerrit Holl (17) from Diemen (Amsterdam), I'm between school and
university (Physics), I learned programming using Python 4 1/2 years
ago and it's still the only real language I know, so I'm far from an
expert in computer science. I have been lurking this mailinglist for
approximately half a year now.

Martin v. Löwis wrote:
> "Fred L. Drake, Jr." <fdrake@acm.org> writes:
> 
> > I'll note that I'm not against the idea, but getting the semantics
> > just right won't be nearly so easy.  If someone does the work to
> > figure it out and produces a working patch, I'll be more than happy to
> > take a look at it.
> 
> I felt that the semantics of pprint are sufficiently vague so that
> trading one instance of "correct" vs. another is acceptable. pprint
> should be used for debugging output only, where the specifics of the
> output are not that relevant, as long as it looks "pretty".
> 
> In any case, I have told Gerrit your ruling; we'll see whether he
> comes back with a new patch.

Would it be an acceptable solution to check whether __repr__ has changed?

Something like:

    if issubclass(typ, dict) and type(typ.__repr__) is type(dict.__repr__):
        # do stuff

Objects that don't change __repr__ can "safely" be pprinted, objects that
do but still want to pprint their data can subclass PrettyPrinter.

If this is considered a correct change, I will attach a new patch to SF#750542.

yours,
Gerrit.

-- 
114. If a man have no claim on another for corn and money, and try to
demand it by force, he shall pay one-third of a mina of silver in every
case.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/