nested_scopes with execfile

Jeff Shannon jeff at ccvcorp.com
Thu Mar 21 16:11:11 EST 2002


Amir Hadar wrote:

> Thanks for repalying.
>
> I suppose you are right but this is not the correct behaviore with
> nested_scopes on. As I anderstend execfile should behave as if I cut
> and past the file to that position my self (as appose to import).

I think (though I'm not in a position to test) that your problem comes from the fact that future directives
only apply to the current file.  When Test2.py is compiled, nested_scopes is not active. You have two options
that I can see, that should fix your problem.

One is to simply require that *all* files import nested_scopes.  Of course, depending on the situation
regarding your control of other developers, this may not be feasible.

The other solution is to use Python 2.2, in which nested scopes are the default.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list