[Python-Dev] Draft: PEP for imports

Armin Rigo arigo at tunes.org
Fri Jan 30 08:32:53 EST 2004

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

where the semantics would be to search sys.path if and only if no 'in' clause
is specified.  ('in' doesn't sound quite right...)


More information about the Python-Dev mailing list