+ 1
What is the problem here? I cannot understand where am i wrong
#A little program to understand the Classes #P.S. i am a beginner and i want to check if the class C include the arguments of class Angel. Don't hate :) class Angel: def __init__(self, eyes, hair): self.eyes = eyes self.hair = hair class B(Angel): def my_func(self,height): self.height = height class C(B): def my_func2(self,weight): self.weight = weight hello = Angel("Blue", "Brown") print(C.eyes)
3 Answers
+ 1
why not print(hello.eyes)
call the member property through the object
+ 1
if you want to access eyes statically use it as an attribute in class Angel outside of __init__
like :
class Angel:
eyes = ""
def __init__(self, eyes, hair):
self.eyes = eyes
self.hair = hair
class B(Angel):
def my_func(self,height):
self.height = height
class C(B):
def my_func2(self,weight):
self.weight = weight
hello = Angel("Blue", "Brown")
Angel.eyes = "red"
print(C.eyes)
0
Lily Mea , i want to check if the class C includes the arguements of class Angel