我正在Python中创建一个类(class0),它目前基于一个类(class1); 但是,我也希望从另一个类继承(class2).关于class2的事情是我不想要它的所有方法和属性,我只需要一个方法.class0是否可以仅从class2继承单个方法?
我有两个类,例如:
class Parent(object):
def hello(self):
print 'Hello world'
def goodbye(self):
print 'Goodbye world'
class Child(Parent):
pass
Run Code Online (Sandbox Code Playgroud)
class Child必须只从Parent继承hello()方法,并且不应该提及goodbye().可能吗 ?
ps是的,我读过这个
重要说明:我只能修改Child类(在所有可能的父类中应保留原样)