Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eb24eeb

Browse files
added super() ✔
1 parent b9eafb0 commit eb24eeb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎Beginner_Level/super( ).py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
class Parent:
3+
def __init__(self, name):
4+
print('Parent __init__', name)
5+
6+
7+
class Parent2:
8+
def __init__(self, name):
9+
print('Parent2 __init__', name)
10+
11+
class Child(Parent, Parent2):
12+
def __init__(self):
13+
print('Child __init__')
14+
super().__init__('chamn') # to call the __init__ of superclas
15+
# Parent.__init__(self, 'ram')
16+
# Parent2.__init__(self, 'max')
17+
18+
child = Child()
19+
print(Child.__mro__) # mro method resoution order. After running u can see that 1st method of child class executed then parents class method
20+
21+

0 commit comments

Comments
(0)

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