Importing and source structure troubles

Tiago Stürmer Daitx tdaitx at gmail.com
Fri Jun 3 08:15:26 EDT 2005


The "best" way depends on how you have structured your program. From
what you've told I believe that setting the directories like
 dir1
    dir2
    dir3
 
is a good approach.
 
As for the import errors you're getting, check this section from the tutorial:
    http://docs.python.org/tut/node8.html#SECTION008400000000000000000

It describes how to setup packages in Python - and that's exactly what
you need. You'll see that in order to import dir3 from dir2 you must
import the full name of the package (ie. import dir1.dir3). See the
intra-packages reference
    http://docs.python.org/tut/node8.html#SECTION008420000000000000000 
 

Regards,
Tiago S Daitx
On 6/3/05, Echo <oshecho at gmail.com> wrote:
>  Hello,
>  
>  I am having trouble with putting the source for a program I am working on in different directories.
>  I have the directories set up like this:
>  
>  dir1
>    dir2
>    dir3
>  
>  I want the source in dir2 to be able to import from the source in dir3(is this possible). I get import errors when I tried doing this.
>  
>  A less preferred structure that I tried was like this:
>  dir1
>    dir3
>      dir2
>  
>  I thought that this way would work. but this way I get even more import errors. two files in dir2 have a 'from dir3.dir2 import bla' however, in one of the files, I get an import error. any idea why this is??
>  
>  What is the best way to structure the program I am working on? I have 3 groups of source files. One has the files that start the program and some tools. Another group has all the main files. And the last group is just some misc stuff. How would the best way to accomplish this be?
>  
> -- 
> -Echo  
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>



More information about the Python-list mailing list