[Python-Dev] Decimal conversion to string

Aahz aahz at pythoncraft.com
Thu Apr 15 10:29:41 EDT 2004


On Thu, Apr 15, 2004, Guido van Rossum wrote:
>Greg Ewing:
>>
>> But who cares about the gory details of the internals?  The most
>> important thing about a repr() is to unambiguously indicate the
>> object's type; the next is to show something about its value, as far
>> as reasonably possible. What's actually inside the object doesn't
>> matter much.
>
> I didn't see the start of this, but the guidelines for repr() are and
> have always been this: if at all possible it should be an expression
> that, when fed to eval(), (assuming the right imports are in scope),
> returns an object with the same type and value.  In most cases, this
> means it should resemble a call to the constructor with suitable
> arguments.  If that isn't possible, a form surrounded with <...>
> should be used, and it should at least show the object's type and some
> stuff that can be used to distinguish different instances (either the
> address or some representative property of the instance).

Right.  Question is, to what extent does "human readable" factor in
after these criteria?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I used to have a .sig but I found it impossible to please everyone..."  --SFJ



More information about the Python-Dev mailing list