Created
November 9, 2018 14:50
-
-
Save dominik-ba/2435d299136d80fcf460f14949036ec9 to your computer and use it in GitHub Desktop.
loads dynamically a method in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FunctionAttributeMapping(AttributeMapping): | |
def __init__(self, method, targetName): | |
AttributeMapping.__init__(self) | |
self.__method = method | |
self.__targetName = targetName | |
def getValue(self, ci): | |
import sys | |
modname = globals()['__name__'] | |
module = sys.modules[modname] | |
method = self.__method | |
module = __import__(module) | |
return getattr(module, method)(ci) | |
def getTargetName(self): | |
return self.__targetName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment