import
faulkner
faulkner612 at comcast.net
Wed Jul 5 16:48:07 EDT 2006
that should be __init__.py [TWO underscores].
and you might want to import sys and check sys.path [the list of
directories searched by the import mechanism].
David Jackson wrote:
> Hi all,
>
> I'm a real beginner with python but have what I think is a simple question.
> I am writing some simple modules and would like to place them into a
> subdirectory. But then I cannot seem to import them. I have tried the
> following.
>
> I wrote a module called fibo.py with some definitions in it (one called
> fibo). In the same directory, I wrote another file (test.py) and began with
> import fibo. This worked fine and I was able to use the function fibo as
> fibo.fibo. Then, I made a directory called test and placed the file fibo.py
> in this directory. I also placed a blank file called _init_.py into this
> directory. I went back to the original directory and tried to import
> test.fibo but this fails. I get the following error message:
>
> Traceback (innermost last)
> File "...test.py", line 1, in ?
> import test.fibo
> File "...test.py", line 1, in ?
> import test.fibo
> ImportError: No module named fibo
>
> Any help would be greatly appreciated. If it makes any difference, I'm
> working on a Mac, OSX 10.3.9
>
> Thanks,
> David
More information about the Python-list
mailing list