vendredi 16 janvier 2015

Can I dinamically determine module and class to be used? [duplicate]


This question already has an answer here:




I am not sure how to word this.


Basically, what am I looking for is a way to call a method from a variable class.


Something like this:



var = "MyWonderfulClass"
module = "my_wonderful_class"
if $module.$class.likes_spam():
print("I like trains")


How to do this?


EDIT: I do not want to load modules dinamically, I want to call methods of a module/class determined at run time.






Aucun commentaire:

Enregistrer un commentaire