Hi
How can I run the function from function name?
Here what I have and it gives me an ERROR. Can someone explain why and how to fix it.
Thanks
CMD = ["02", "A0"]
import ConstantsGlobal as GCONST
class Test(object):
def __init__(self):
self.__dic = dict(("0x"+f, "self.__CMD"+f) for f in GCONST.CMD)
def runCmd(self):
func = getattr(self, self.__dic["0x02"]) # even if I add eval(self.__dic["0x02"]) -> Not Working
func()
def __CMD02(self):
print "02"
def __CMDA0(self):
print "A0"
if __name__ == "__main__":
t = Test()
t.runCmd()
--
Mark