Imports again...

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Apr 9 10:19:58 EDT 2010


On 8 abr, 10:16, Alex Hall <mehg... at gmail.com> wrote:

> Hello all, once again:http://www.gateway2somewhere.com/sw/sw.zip
> 
> The above link is to a project. I am new to using multiple files in
> Python, and I have a lot of tangled imports where many files in the
> same folder are importing each other. When I tried to follow the
> manual to make some files into packages, it did not work. Can anyone
> explain why I am getting an import error in the above project, and/or
> how I can clean up the file structure and imports to avoid problems
> like this in the future? Thanks in advance for any help, and I
> apologize for the broken link the other day.

In addition to what Tim Golden has said (which appears to be based on another 
version of this project - I don't see the file structure he describes), I 
noticed that weather.py spawns a new thread when imported; don't do that: 
http://docs.python.org/library/threading.html#importing-in-threaded-code

Also, you have some .pyw files with corresponding .pyc file. That's *very* 
strange. .pyw files are *not* modules, and Python won't import them. Don't use 
the .pyw extension except for your main application script (in cases when you 
don't want a console window to appear). Having foo.pyc and foo.pyw in the same 
directory, Python will always load the .pyc file, ignoring any changes in 
the .pyw source.

-- 
Gabriel Genellina




More information about the Python-list mailing list