function namespaces
Max Erickson
maxerickson at gmail.com
Tue Mar 8 19:15:15 EST 2005
Darren Dale wrote:
> def myfunction(filename):
> execfile(filename)
> print testvar
>
> What am I doing wrong?
I'm not familiar enough with execfile or the interactive interpreter to
know what you are doing wrong, but something like:
def myfunction(filename):
ns=dict()
execfile(filename, ns)
print ns['testvar']
should at least get you going. There is probably a way to pass the
namespace of the function to execfile, but I do not know it.
max
More information about the Python-list
mailing list