Can I import from a directory that starts with a dot (.) ?
Gary Herron
gherron at islandtraining.com
Tue Apr 14 02:32:25 EDT 2009
Matthew Wilson wrote:
> I want to have .foo directory that contains some python code. I can't
> figure out how to import code from that .foo directory. Is this even
> possible?
>
> TIA
>
> Matt
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Python starts up with a list of directories to search when importing.
You can append your directory to that list, and then import as you wish.
import sys
sys.path.append('/...path-to.../.foo')
import someModule # would find and import .foo/someModule.py
You may also enjoy printing the contents of sys.path to see the list of
directories Python starts with.
Gary Herron
More information about the Python-list
mailing list