Calling a function dynamically

Paradox JoeyTaj at netzero.com
Thu Jan 8 16:42:14 CET 2004


I would like to call a function whose name I supply at runtime.
Something like this but it didn't work

functionName = 'run'
instance = ClassDef()
args = [1, 2]

#want the dynamic equivalant of
#instance.run(*args)

#This didn't work cause there was no __call__ attribute. Why?
value = instance.__call__[functionName](*args)




               Thanks Joey



More information about the Python-list mailing list