python - inheritance, necessity of __init__ -
the link below nice, gives example if inheritance without having not-so-nice looking foo.__init_(...)
foo
soon-to-be subclass of class bang
: class foo(bang):...
https://docs.python.org/3.3/tutorial/classes.html#private-variables
question: if want create new variables inside class, self._biz
? must create __init__
method?
yes, if want create instance variables, should override __init__
(and sure call parent class's implementation, too).
Comments
Post a Comment