promoting [] by superclass?

Tor Iver Wilhelmsen tor.iver.wilhelmsen at broadpark.no
Tue Jun 8 22:39:50 CEST 2004


Jim Newton <jimka at rdrop.com> writes:

> class x1(list):
>    def __init__(y):
>       pass

You lack a "self" argument there for it to be a real initializer.

> what does x1([]) do and what does x2([]) do?

>>> x = x1([])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __init__() takes exactly 1 argument (2 given)

x2([]) works though, since it uses the __init__ in list.



More information about the Python-list mailing list