I am trying to create a class derived from list
so that it can have size
and some other functions with following code:
class Mylist(list):
def size(self):
return len(self)
I can add other function similar to above.
I can create Mylist
object with following code:
ll = Mylist([1,2,3])
But how can I add code so that when I create an object with following code, I get Mylist
object and not usual list
object:
ll = [1,2,3]
I have not been able to figure out how to do this. Thanks for your help.