Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Fixed Error
Source Link
Jacob Lee
  • 4.7k
  • 2
  • 20
  • 40

The child class would have to inherit the parent self attribute to do that.

class Animal:
 def __init__(self, name):
 self.name = name
 class Mammal:
 def Presentation(inherit):
 print(inherit.name + "is a mammal")
dog = Animal("Dog")
Animal.Mammal.Presentation(dog)

The child class would have to inherit the parent self attribute to do that.

class Animal:
 def __init__(self, name):
 self.name = name
 class Mammal:
 def Presentation(inherit):
 print(inherit.name + "is a mammal")
dog = Animal("Dog")
Mammal.Presentation(dog)

The child class would have to inherit the parent self attribute to do that.

class Animal:
 def __init__(self, name):
 self.name = name
 class Mammal:
 def Presentation(inherit):
 print(inherit.name + "is a mammal")
dog = Animal("Dog")
Animal.Mammal.Presentation(dog)
Source Link
Jacob Lee
  • 4.7k
  • 2
  • 20
  • 40

The child class would have to inherit the parent self attribute to do that.

class Animal:
 def __init__(self, name):
 self.name = name
 class Mammal:
 def Presentation(inherit):
 print(inherit.name + "is a mammal")
dog = Animal("Dog")
Mammal.Presentation(dog)
lang-py

AltStyle によって変換されたページ (->オリジナル) /