I searched other posts in stackoverflow and even copied them to try on my machine as answered. However, it keep failing throwing "TypeError"
# this is as one of other post in StackOverflow.
class ListClass(list):
def __init__(self, *args):
super().__init__(self, *args)
self.append('a')
self.name = 'test'
I also tried empty class with pass. But, that also fails if I inherit and I guess I missed something instead of adding something more or wrong?
1) what is this "TypeError"
and why?
2) how to fix it?
further snapshot on TypeError:
>>> class ListClass(list):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list() takes at most 1 argument (3 given)
You are giving it to many paramerters when you create the ListClass object, this is what you are doing:
s = list(2,3,3)
This is what you shuold be doing:
s = list([2,3,3])
Try this snippets on you interpreter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With