class Test:
def __init__(self, number):
self.number = number
def getnumber(self):
return self.number
x = Test(54)
y = 'number'
print x.getnumber()
try:
print(eval('%s.%s'% (x, y)))
except Exception, e:
print(e)
This isn't the code I want to fix, but it has the same error. I am trying to return a class function on runtime, but it does not work. What am I doing wrong?