I'm Java person who just started learning Python. Take this example:
class Person():
def __init__(self, name, phone):
self.name = name
self.phone = phone
class Teenager(Person):
def __init__(self, name, phone, website):
self.name=name
self.phone=phone
self.website=website
I'm sure there's a lot of redundant code (I know in Java, there are a lot of redundancies for the bit of code above).
Which parts are redundant with respect to which attributes are already inherited from the parent class?
object
as a base class ofPerson
in order to usesuper()
. Otherwise, you have to use thePerson.__init__
form. – Lukash