Can I import from a directory that starts with a dot (.) ?
gherron at islandtraining.com
Tue Apr 14 08:32:25 CEST 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
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 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.
More information about the Python-list