Taban ve Türemiş

This commit is contained in:
Mert Gör ☭ 2023-07-02 16:12:05 +03:00
parent 7280eead01
commit 12bf1e6adf
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
class A:
def __init__(self):
print('A __init__ called: {}'.format(type(self)))
self.x = 10
def dispA(self):
print('A.Disp: {}'.format(self.x))
class B(A):
def __init__(self):
print('B __init__ called: {}'.format(type(self)))
super(B, self).__init__()
self.x = 20
def dispB(self):
print('B.Disp: {}'.format(self.x))
b = B()
b.dispB()
b.dispA()