[Python-Dev] Re: Christmas Wishlist

Charles Hixson charleshixsn at earthlink.net
Wed Dec 17 11:55:40 EST 2003


Barry Warsaw wrote:

>On Mon, 2003-12-15 at 11:52, Skip Montanaro wrote:
>  
>
> ...
>
>Sorry, let me rephrase.  I'd love to ban relative imports.  Personally,
>I think all imports should be specified using fully-qualified absolute
>package paths.
>
>-Barry
>  
>
If I'm understanding this right you want to ban imports that are machine 
independant.  That can't be right, but that's what it sounds like to me.

To me an "absolute import" or a "fully-qualified absolute package path" 
sounds like you know the exact directory that the import is occuring 
from.  E.g.:  
/home/someone/projects/python/workingprogress/currentproject/thisone.py
I can see the use for being able to import that, but usually I would 
prefer to import either from something relative to the current 
directory, or relative to the python site-lib, or some such.   It's also 
quite nice to not need to bother to exactly specify just  which of those 
I will find it in.  (This is what the pythonpath is for.)

Now to me an import relative to the current directory is a relative 
import, and I assume that this is also what is meant by a local import.  
By allowing files to cluster relative to the code being written one is 
able to keep related projects and libraries together rather than just 
having all the code spread out aimlessly in a huge flat directory.  I 
don't see in what what this is inferior.

Since you didn't say why you wanted to ban relative imports, I don't 
understand your reasons.  I can't even guess at them.  Even if it were 
for some efficiency condern about hierarchical directories, that would 
merely say that the compiled modules should be stuffed into a library 
folder.  (Well, more than one...the user needs to have write permission 
to the libraries that he creates, but it's just as well that he not have 
write permissions to the system libraries...without taking special steps.)




More information about the Python-Dev mailing list