Module import problems

Peter Hansen peter at engcorp.com
Mon Apr 5 12:46:54 EDT 2004


simo wrote:

> So I think the login class is failing to initialise as it can't find
> the wx class imported in main.py, because if I run login.py then I get
> "...wx not defined" surely I don't have to import wx in every file
> (that doesn't work actually)?!

Yes, of course you do.

> This namespace crap is becomming an inconvenience - jees, do we have
> to make everything global?!

Really, it's not at all that difficult.  Anyway, the namespaces are
there to protect you and simplify the code.  Although you could think
of it as a small inconvenience to have to put imports for various
things wherever you need them, the alternative is vastly more of a
problem.

> Also, does IDLE cache the compiled Python or something, as sometimes
> when I change a file and save/run it in the shell, it doesn't change
> (I do delete the .pyc files) until I quit and reload IDLE?

I never use IDLE, so I can't say.  My preferred approach is simply
running things from the command line (but you get that way when you
start focusing on unit testing rather than code-and-fix...).

-Peter



More information about the Python-list mailing list