[Python-Dev] Draft: PEP for imports

Jp Calderone exarkun at intarweb.us
Fri Jan 30 09:26:13 EST 2004


On Fri, Jan 30, 2004 at 01:32:53PM +0000, Armin Rigo wrote:
> Hello Guido,
> 
> On Sun, Jan 25, 2004 at 01:59:16PM -0800, Guido van Rossum wrote:
> >   from /home/guido/lib/python import neatTricks
> 
> Keeping the amount of magic behind import as low as possible seems very
> important, because they are not a minor feature but something that every
> beginner must reasonably understand; I've already seen it as an obstacle.  
> The above statement has the advantage of looking obvious; but in addition to
> the package name problem there is the fact that directory names are not always
> valid Python identifiers.  A last try:
> 
>   import neatTricks in "/home/guido/lib/python"      # no package
>   import package.module in "/home/guido/lib/python"  # package
>   import foo in "."                                  # relative import
>   from neatTricks in "../cmds" import a, b, c
>   s=os.path.join("some", "where"); import foo in s   # expression path
> 

  An experienced Python programmer could probably use this to some
advantage, but I think many beginners would use it without realizing it will
very easily result in a piece of software which is completely
undistributable.

  They may save some time up front by not having to understanding how the
rest of the import system works, but will it be more time than they have to
spend later trying to fix their app so it runs on systems other than the one
it was developed on?

  Jp



More information about the Python-Dev mailing list