newbie-ish question on exec statement
Gabe Newcomb
Gabe.Newcomb at noetix.com
Mon Mar 11 21:12:15 EST 2002
Hi all:
I'd appreciate any comments people might have on the limitations
of using exec. Specifically, what I want to do is build function names
dynamically and call them (don't ask why).
The function I'm using is one that accepts 3 arguments, the second and
third of which have default values.
The function returns a tuple of 2 values.
I'm calling the function with only one argument, e.g.,
def my_function(arg1, arg2="", arg3=""):
blah blah
exec "t = my_" + "function('\\\\machine\\share')"
I have a feeling that something unexpected (by me anyway) is happening
with the string I'm trying to pass in as the arg to my_function()--this
is based on the response I'm getting from my function. When I type the
same text (t = my_" + "function('\\\\machine\\share')) into the
interpreter directly, everything's fine.
Is this perhaps only an issue with the interpreter, where I'm testing
this?
Thanks in advance,
Gabe Newcomb
More information about the Python-list
mailing list