Why I need to declare import as global in function
fredrik at pythonware.com
Tue Nov 29 15:34:45 CET 2005
Duncan Booth wrote:
> That is unlikely to help. The execfile target seems to have been
> TU_05_010.py, but the file which cannot access math is TU_05_tools.py
> accessed by a normal import, so adding some globals to the execfile call
> won't really do anything useful.
> Isn't it fun trying to guess the problem in the absence of the code?
given that the NameError occurs on line 2 of the file, inside a function, this
is probably just a misunderstanding of how namespaces work in Python...
More information about the Python-list