Call a function using a variable

Bjorn Pettersen BPettersen at NAREX.com
Fri Apr 27 15:48:06 EDT 2001


> From: Colin Meeks [mailto:colinmeeks at home.com]
> 
> Does anybody know if it's possible to do something along the 
> following lines
> :
> 
> myfunction="test"
> x=myfunction
> 
> Basically what I want is when the x variable gets declared it 
> get's it's
> data from the function test()

myfunction = eval('test')
x = myfunction()

of course, if you're not sure what you're passing to eval you might get
surprising results <wink>

-- bjorn




More information about the Python-list mailing list