What's wrong with this code?
class MyList(list):
def __init__(self, li): self = li
When I create an instance of MyList
with, for example, MyList([1, 2, 3])
, and then I print this instance, all I get is an empty list []
. If MyDict
is subclassing list
, isn't MyDict
a list
itself?
NB: both in Python 2.x and 3.x.
list.__init__(self)
also work when inheriting fromlist
? – Woollen