I just started learning Python, and created the following class, that inherits from list:
class Person(list):
def __init__(self, a_name, a_dob=None, a_books=[]):
#person initialization code
list.__init__(a_books)
self.name = a_name
self.dob = a_dob
However, there are three things I don't understand:
- This line
list.__init__(a_books)
, doesn't actually initialize my instance's list of books. - I am supposed, according to the book, write
list.__init__([])
instead. Why is this step necessary. - Why is there no reference to
self
inlist.__init__([])
? How does Python know?