我是Python新手。從基類調用函數
我有一個類有一些常見的定義,將用於模塊中的其他幾個類。這是我的程序的當前結構。
class A(object):
def __init__(self, x, y):
"""Initialization method"""
super(A, self).__init__()
self.x = x
self.y = y
def function_1(self, ftype):
<<<some steps>>>
return abc
def function_2(self, stype):
<<<some steps>>>
return xyz
class B(A):
def __init__(self, x, y, e_type):
A.__init__(self, x, y)
self.e_type = enablement_type
def function_3(self, mtype):
<<<some steps>>>
**HERE I need to call the function1 and function2 of class A**
1:打電話是從基類中的功能
A.function1(self, ftype='new')
A.function2(self, stype='new')
是正確的方法是什麼? Pylint說,當我這樣做的時候一切都很好。
2:另外,你能在簡單的條件,並請
我會建議您[ 「Python入門」(https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjc9s7tv73TAhXKrY8KHZ_oAxwQFggiMAA&url=http% 3A'2F%2Fstock.ethop.org%2Fpdf%2Fpython%2FLearning%2520Python%2C%25205th%2520Edition.pdf&usg = AFQjCNH2hxNCd_36JzxBTsnu2R8238dF_A&sig2 = FcfkvLSeVGgY1OqEDEEENQ)Oops page 781 Part VI –