Rich __repr__

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Oct 31 08:10:30 CET 2005


Howdy all,

The builtin types have __repr__ attributes that return something nice,
that looks like the syntax one would use to create that particular
instance.

The default __repr__ for custom classes show the fully-qualified class
name, and the memory address of the instance.

If I want to implement a __repr__ that's reasonably "nice" to the
programmer, what's the Right Way? Are there recipes I should look at?

-- 
 \     "For certain people, after fifty, litigation takes the place of |
  `\                                              sex."  -- Gore Vidal |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list