defining __repr__

Gerrit Holl gerrit at nl.linux.org
Thu Sep 15 13:22:54 EDT 2005


sven wrote:
> i'd like to define __repr__ in a class to return the standardrepr
> a la "<__main__.A instance at 0x015B3DA0>"
> plus additional information.
> how would i have to do that?
> how to get the standardrepr after i've defined __repr__?

>>> object.__repr__(4)
'<int object at 0x94f7d8c>'

Gerrit.

-- 
Temperature in Luleå, Norrbotten, Sweden:
| Current temperature   05-09-15 19:19:58    7.8 degrees Celsius ( 46.0F) |
-- 
Det finns inte dåligt väder, bara dåliga kläder.



More information about the Python-list mailing list