+ 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)

4th Apr 2020, 4:21 PM
Angelos Karasavvidis
Angelos Karasavvidis - avatar
3 Respostas
+ 1
why not print(hello.eyes) call the member property through the object
4th Apr 2020, 4:29 PM
durian
durian - avatar
+ 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)
4th Apr 2020, 5:35 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
Lily Mea , i want to check if the class C includes the arguements of class Angel
4th Apr 2020, 4:45 PM
Angelos Karasavvidis
Angelos Karasavvidis - avatar