Making a list-inhereted object return standard repr?
Philip Swartzleonard
starx at pacbell.net
Fri Feb 1 23:23:40 EST 2002
Ok, so i decided to make my container class inherit from list,
considering that that's basically what it is. Now i've run into a problem
where my self_parent exception is being raised for whatever reason, and the
first thing i try is sticking a 'print self, assigend' sort of statement at
the beginning of the function. The problem is, instead of getting something
like '<__main__.mapcell instance at 0xf00fee>', i get '[]'. I want to
change __repr__ and __str__ to do something more like the first case again
(possible with an added 'containing [...]' element), but the only
information i can find to build it out of is what's available from id() and
type(), ... i can't find something that lets me mimic the first part of the
message (id is useful, type isn't).
Thanks.
--
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com
More information about the Python-list
mailing list