This question already has an answer here:
Can any one help me to inherit multiple classes in python.
Let say I have three classes in three different modules.
a.py :
class A():
def __init__(self):
pass
def fruit(self):
print "Apple is a fruit"
b.py :
class B():
def __init__(self):
pass
def vegetable(self):
print "Potato is a vegetable"
c.py :
class C():
def __init__(self):
pass
def vehicle(self):
print "Car is a vehicle"
I just want to configure all these class names in a file like , a.A , b.B and c.C. then read the configuration file and load the configured modules and inherit those modules( Multiple Inheritance ).
utility.py
Read configuration and get the modules.
class Utility(INHERIT_CONFIGURED_MODULES):
def __init__(self):
pass
obj = Utility()
obj.fruit()
obj.vegetable()
obj.vehicle()
Now ,If I create one more module and configure that in my configuration file,then I should access its methods using the objected created for Utility class.
Hope its clear.Please guide me to achieve this.
Aucun commentaire:
Enregistrer un commentaire