user defined modules
Rick Johnson
rantingrickjohnson at gmail.com
Sun Jun 10 15:17:32 EDT 2018
Sharan Basappa wrote:
> Is there a specific location where user defined modules
> need to be kept?
My advice is that any location is a good location so long as
the location you chose is _not_ a part of the PythonXY
directory tree.
For example, on a windoze machine (and in Python2.x at
least), the PythonXY directory is placed (by default) at the
root of the default drive (usually C drive). Your scripts
(on a windows machine) should be (idealy) somewhere in the
os.path.expanduser('~/Documents') tree.
Personally i use a .pth file to point Python in the
direction of my library modules. Unlike the old time
masochist, i just hate having to repeat myself. Thus, like
most modern folk, i have learned that copy+paste and "set-
it-and-forget-it" text file are a computer users best
friend and loyal companions.
## MAP ##
C:/
PythonXY/
config.pth
The contents of my .pth file is simply an unquoted string
representing the path to my library folders. (something like
this)
## PTH FILE CONTENT ##
C:/.../Documents/path/to/my/lib/folder
That's it!
More information about the Python-list
mailing list