promoting [] by superclass?

Jim Newton jimka at
Tue Jun 8 17:30:42 CEST 2004

wow that is great.

now the other question:

class Pair(list):

how can i "cast",  "promote" [] to class Pair?

Erik Max Francis wrote:
> Jim Newton wrote:
>>if that is the case then why does the following fail
>>class another:
>>        pass
>>I would think that would return a string such as
>>"<__main__.another instance at 0x8132b64>"
>>but it does not seem to.
> Because __str__ is a special method which str defers to.  If you want
> the str of anObject, call str(anObject).  The object will then show you
> the string representation for that object.  You shouldn't care whether
> or not it's got that behavior from defining a __str__ method, or whether
> it's gotten it from a parent class.

More information about the Python-list mailing list