dynamic func. call
Tim Jarman
tmj at SPAMLESSjarmania.com
Fri Feb 4 09:19:48 EST 2005
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 = myFunction
just binds the name s to your function object, and therefore:
a = s()
is the same as:
a = myFunction()
--
Website: www DOT jarmania FULLSTOP com
More information about the Python-list
mailing list