[Tutor] import question

Ryan Davis ryan at acceleration.net
Fri Jan 7 22:08:42 CET 2005


Hello all,
 
I'm just starting to use python seriously, and am having problems understanding exactly what is going on with import statements and
the sys.path variable.
 
I'm trying to import classes and functions across several directories.  Here's a simple example of my filesystem:
/Defs
      base.py
      /One
            a.py
            b.py
      /Two
            c.py
 
In a.py I have:
###
import b
###
This results in an error:
ImportError: No module named b
 
My sys.path contains the absolute path to /Defs/One, so, if I'm understanding the import documentation
(http://www.python.org/doc/current/ref/import.html), then the import statement should be searching the list of directories in
sys.path, and finding it, but instead I get the ImportError.
 
I'm using Python 2.3.4 on Windows XP, using Xemacs to develop it and debug as I go using the interpreter.  Could this be something
weird about how xemacs is running the code?
Thanks,
Ryan 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050107/882b2390/attachment.html


More information about the Tutor mailing list