Re: Can anyone tell me if pygame and Tkinter can work together?
- From: "Fredrik Lundh" <fredrik@xxxxxxxxxxxxxx>
- Date: Wed, 16 Nov 2005 21:03:06 +0100
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:
http://docs.python.org/ref/naming.html
</F>
.
- Follow-Ups:
- Re: Can anyone tell me if pygame and Tkinter can work together?
- From: Nathan Pinno
- Re: Can anyone tell me if pygame and Tkinter can work together?
- References:
- RE: Can anyone tell me if pygame and Tkinter can work together?
- From: Nathan Pinno
- Re: Can anyone tell me if pygame and Tkinter can work together?
- From: Nathan Pinno
- Re: Can anyone tell me if pygame and Tkinter can work together?
- From: Simon Brunning
- Re: Can anyone tell me if pygame and Tkinter can work together?
- From: Nathan Pinno
- RE: Can anyone tell me if pygame and Tkinter can work together?
- Prev by Date: Re: creating package question
- Next by Date: readline vi mode in python interactive shell
- Previous by thread: Re: Can anyone tell me if pygame and Tkinter can work together?
- Next by thread: Re: Can anyone tell me if pygame and Tkinter can work together?
- Index(es):