I have two versions of a script on my machine. One version is for newif you already have two different versions of the script, what stops you
development and the other version is a production version. This script
imports a module from a different directory, and this module again has
two versions (a development version and a production version). What I
want is for the development script to import the development module, and
the production script to import the production module, without making
any changes to the code in the script.
from making changes to them?
For example, suppose the development script is in ~/dev/rss.py, and thecannot you just insert the appropriate directory in sys.path the first
production script is in ~/prod/rss.py. I want the dev version to import
/usr/lib/python2.5/site-packages/lib_dev/parse.py, and the prod version
to import usr/lib/python2.5/site-packages/lib_prod/parse.py.
thing you do in the scripts? e.g.
import os, sys
lib = "lib_dev" # change this for prod/rss.py
sys.path.insert(0,
os.path.join(
os.path.dirname(os.__file__), "site-packages", lib
))
import parse # picks the right one
</F>