Skip to content

Commit 03bed6a

Browse files
committed
answer for the question related to the error at the last line
1 parent b3a0fde commit 03bed6a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

prep_exercises/exercise9inheritance.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ def get_full_name(self) -> str:
4646
#Traceback (most recent call last):
4747
# File "/Users/Module-Decomposition/prep_exercises/exercise9inheritance.py", line 34, in <module>
4848
# print(person2.get_full_name())
49-
#AttributeError: 'Parent' object has no attribute 'get_full_name'
49+
#AttributeError: 'Parent' object has no attribute 'get_full_name'
50+
51+
#This error on the last line means since there is no method called get_full_name in Parent class(it is only defined in child),
52+
#python rises the attribute error on parent and inheritance works downward so the child can have what the parent have but not the reverse.
53+
#and hence get_full_name is only for the child and it can not be inherited to the parenet.

0 commit comments

Comments
 (0)