Re: dynamic func. call

2005-02-06 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > Try this: > > def myfunc(): > print "helo" > > s = "myfunc()" > a = eval(s) > No, please don't try that. Good uses for eval are *very* rare, and this isn't one of them. Use the 'a = locals()[x]()' suggestion (or vars() instead of locals()), or even better put al

Re: dynamic func. call

2005-02-04 Thread [EMAIL PROTECTED]
Try this: def myfunc(): print "helo" s = "myfunc()" a = eval(s) -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic func. call

2005-02-04 Thread Tim Jarman
Aljosa Mohorovic wrote: > can i do something like this: > > s = "myFunction" > a = s() # equals to: a = myFunction() Functions are first-class objects in Python, so you can do: def myFunction(): # whatever which creates a function object and binds the name myFunction to it. Then: s = myFu

Re: dynamic func. call

2005-02-04 Thread Ola Natvig
Aljosa Mohorovic wrote: can i do something like this: s = "myFunction" a = s() # equals to: a = myFunction() a = locals()[x]() locals() returns a dictionary with string keys that you can use -- -- Ola Natvig <[EMAIL PROTECTED]> infoSense AS / development -- ht

dynamic func. call

2005-02-04 Thread Aljosa Mohorovic
can i do something like this: s = "myFunction" a = s() # equals to: a = myFunction() -- http://mail.python.org/mailman/listinfo/python-list