__str__ vs. __repr__

Toby Dickenson htrd90 at zepler.org
Sun Nov 7 09:13:20 EST 1999


Guido van Rossum <guido at cnri.reston.va.us> wrote:

>Bernhard Herzog <herzog at online.de> writes:
>
>> How about a hook function a la __import__? I.e. have a function
>> __format__ [1] in __builtin__ that is bound to repr by default. Whenever
>> Python prints the result of an expression in interactive mode, it calls
>> __format__ with the result as parameter and expects it to return a
>> string ready for printing.
>
>Brilliant!  The default function could do all the current built-in
>magic -- print nothing if it's None, assign it to builtin _, and so
>on.
>

...and an IDE could open an object browser window. Mmmmmmmmm.



Toby Dickenson




More information about the Python-list mailing list