You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dad.implicit()
son.implicit()
The use of pass under the class Child: is how you tell Python that you want an empty block. This creates a class named Child but says that there's nothing new to define in it.
Override Explicitly
Alter Before or After:hen you use a Python built-in function named super to get the Parent version to call
When to Use Inheritance or Composition:
Avoid multiple inheritance at all costs, as it's too complex to be reliable. If you're stuck with it, then be prepared to know the class hierarchy and spend time finding where everything is coming from.
Use composition to package code into modules that are used in many different unrelated places and situations.
Use inheritance only when there are clearly related reusable pieces of code that fit under a single common concept or if you have to because of something you're using.
chapter46,47
The text was updated successfully, but these errors were encountered:
Implicit Inheritance:
class Parent(object):
class Child(Parent):
pass
dad = Parent()
son = Child()
dad.implicit()
son.implicit()
The use of pass under the class Child: is how you tell Python that you want an empty block. This creates a class named Child but says that there's nothing new to define in it.
Override Explicitly
Alter Before or After:hen you use a Python built-in function named super to get the Parent version to call
When to Use Inheritance or Composition:
Avoid multiple inheritance at all costs, as it's too complex to be reliable. If you're stuck with it, then be prepared to know the class hierarchy and spend time finding where everything is coming from.
Use composition to package code into modules that are used in many different unrelated places and situations.
Use inheritance only when there are clearly related reusable pieces of code that fit under a single common concept or if you have to because of something you're using.
chapter46,47
The text was updated successfully, but these errors were encountered: