def init example
This commit is contained in:
parent
e06b420866
commit
dd19e15c16
18
python-temel/def_init.py
Normal file
18
python-temel/def_init.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
class A:
|
||||
def __init__(self, a):
|
||||
self.a = a
|
||||
|
||||
def dispA(self):
|
||||
print(self.a)
|
||||
|
||||
class B(A):
|
||||
def __init__(self, a, b):
|
||||
A.__init__(self, a)
|
||||
self.b = b
|
||||
|
||||
def dispB(self):
|
||||
print(self.b)
|
||||
|
||||
b = B(10, 20)
|
||||
b.dispA()
|
||||
b.dispB()
|
18
python-temel/def_init.py~
Normal file
18
python-temel/def_init.py~
Normal file
|
@ -0,0 +1,18 @@
|
|||
class A:
|
||||
def __init__(self, a):
|
||||
self.a = a
|
||||
|
||||
def dispA(self):
|
||||
print(self.a)
|
||||
|
||||
class B(A):
|
||||
def __init__(self, a, b):
|
||||
A.__init__(self, a)
|
||||
self.b = b
|
||||
|
||||
def dispB(self):
|
||||
print(self.b)
|
||||
|
||||
b = B(10, 20)
|
||||
b.dispA()
|
||||
b.dispB()
|
Loading…
Reference in New Issue
Block a user