It has been my experience that, more often than not,
any time you think you want to evaluate strings, you
don't need to.
For instance, instead of passing around the name of the
function as a string:
s = someFunction
eval(s)()
you can pass around the function as an object:
s = someFunction #
On Tue, 8 May 2007 09:38:48 +0200, Cesar Härdfeldt wrote
[...]
I now have 'module' and 'function' as strings and 'parms' normally as a list
of strings. I can import the module by __import__(module) but is there
another way to call:
module.function(parms) than using eval()?
On Wed, 02 Nov 2005 19:01:46 -0500, Mike Meyer [EMAIL PROTECTED] wrote:
Paul McGuire [EMAIL PROTECTED] writes:
David Rasmussen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
If I have a string that contains the name of a function, can I call it?
As in:
def someFunction():
print
[EMAIL PROTECTED] (Bengt Richter) writes:
For a lot of uses, it'd be better to build the dictionary by hand
rather than relying on one of the tools that turns a namespace into a
dictionary.
IMO it would be nice if name lookup were as cleanly
controllable and defined as attribute/method lookup.
If I have a string that contains the name of a function, can I call it?
As in:
def someFunction():
print Hello
s = someFunction
s() # I know this is wrong, but you get the idea...
/David
--
http://mail.python.org/mailman/listinfo/python-list
David Rasmussen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
If I have a string that contains the name of a function, can I call it?
As in:
def someFunction():
print Hello
s = someFunction
s() # I know this is wrong, but you get the idea...
/David
Lookup the function in the
David Rasmussen wrote:
If I have a string that contains the name of a function, can I call it?
As in:
def someFunction():
print Hello
s = someFunction
s() # I know this is wrong, but you get the idea...
py eval(someFunction())
'Hello'
py eval(s)() # note the second pair of