Adapt code example in advanced/classes.rst to new handling of forgetting to call the superclass __init__ (#2429)

This commit is contained in:
Yannick Jadoul
2020-08-24 00:00:12 +02:00
committed by GitHub
parent 4493751a5f
commit b3d8fec066

View File

@@ -159,7 +159,7 @@ Here is an example:
class Dachshund(Dog):
def __init__(self, name):
Dog.__init__(self) # Without this, undefined behavior may occur if the C++ portions are referenced.
Dog.__init__(self) # Without this, a TypeError is raised.
self.name = name
def bark(self):
return "yap!"