Can anyone tell me if pygame and Tkinter can work together?
fredrik at pythonware.com
Wed Nov 16 21:03:06 CET 2005
Nathan Pinno wrote:
> It's a warning that says:
> Can only use * in top level or something like that.
> It's kind of annoying
why? importing tons of unknown stuff into a local namespace is
rather silly, and makes it impossible for the compiler to properly
analyze your code -- which means that you cannot use nested
scoping. the language reference says:
The from form with "*" may only occur in a module scope.
If the wild card form of import -- "import *" -- is used in a
function and the function contains or is a nested block with
free variables, the compiler will raise a SyntaxError.
future versions of Python will most likely issue a SyntaxError also
for "import *" in non-nested functions.
> but the program still ran after I made the import * lines top level,
> and removed the def's.
moving the "import *" line to the module scope would have been
enough; functions can refer to module-level variables just fine.
you might wish to read up on Python scoping rules:
More information about the Python-list