How to eval a file

Björn Lindberg d95-bli at nada.kth.se
Sun Feb 23 15:15:11 EST 2003


Alex Martelli <aleax at aleax.it> writes:

> > So, if the globals and locals arguments defaults to the current scope,
> > why don't I have a global variable 'collection' when the execfile returns?
> 
> See the more detailed Python docs online, e.g.:
> http://www.python.org/doc/current/lib/built-in-funcs.html

Thanks.

> If you think it would be helpful to you to understand the reasons
> for this in greater detail, just ask, and I'll be glad to explain
> them further.  But, basically, the bottom line is: not only you
> *shouldn't* call execfile in order to (potentially) destroy your
> function's local namespace, but attempting to do so need not work
> reliably anyway.

Oh, but I have already changed my implementation to actually parsing
my configuration file instead. I continue to ask questions beacuse I
suspect I do not yet fully understand how namespaces work in Python,
and I want to understand it.


Björn




More information about the Python-list mailing list