有没有办法从类继承特定的属性?
例如,
class basic():
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
class inher(basic):
def __init__(self, d, e, f):
self.d = d
self.e =e
self.f = f
def func(self):
# here use 'a' from basic
我知道我可以继承基本的一切:
class inher(basic):
def __init__(self, a, b, c, d, e, f):
basic.__init__(self, a, b, c) #inherit these from basic
self.d = d
self.e = e
self.f = f
有没有办法可以只继承参数' a'从基本?