On 2005-07-27, Paolino <[EMAIL PROTECTED]> wrote:
>> Is there a metalanguage capability in Python (I know there are many) to
>> call a function having its name in a string?
> eval('foo()') should do, but it's said a bad practice ;)
An alternative to eval() is:
>>> def foo():
... print "foo was called"
...
>>> s = "foo"
>>> globals()[s]()
foo was called
>>>
--
Grant Edwards grante Yow! I'm meditating on
at the FORMALDEHYDE and the
visi.com ASBESTOS leaking into my
PERSONAL SPACE!!
--
http://mail.python.org/mailman/listinfo/python-list