repr of type and class objects

Donn Cave donn at drizzle.com
Sat Jan 25 17:15:22 CET 2003


Quoth Erik Max Francis <max at alcyone.com>:
...
| I think you're reading too much into the "philosophy behind repr."  It
| is simply not the case that eval(repr(x)) == x should be true for all x,
| or even all builtin x types.  Even the interpreter help for repr simply
| says "for most object types."

Which has to be an exaggeration, though "for most objects" might
be true.

If repr is really used as a marshalling function, then the people
who are using it ought to be asking for something that can work
more reliably, a dedicated function that doesn't have to produce
something also intended for human eyes.  This function can fall
back on __repr__ the way str does.

If it really isn't seriously needed as a marshalling function, then
that notion ought to be forgotten, and some of the attendant issues
can be resolved (seems to me there was an issue with floating point
precision, for example.)

	Donn Cave, donn at drizzle.com




More information about the Python-list mailing list