Location of Python modules

Szabolcs Nagy nszabolcs at gmail.com
Mon Feb 13 14:04:42 EST 2006


LOL

a .py program is a module, you can import it:
if it is in the sys.path (import modulename).
if it sits in a directory that is in the sys.path and the directory
also has a __init__.py file (import dirname.modulename / from dirname
import modulname).
if there is a modulename.pth file in the sys.path containing the path
to your .py file.
(the current dir is always in the sys.path).

if you want to install your module (copy it under the site-packages
dir), then you should use distutils module and create a setup.py script

the compiled bytecode (.pyc file) is always automatically generated




More information about the Python-list mailing list