Importing different versions of a module

mercado mercado mercado949 at
Fri Jul 18 01:14:56 CEST 2008

I have two versions of a script on my machine. One version is for new
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.

For example, suppose the development script is in ~/dev/, and the
production script is in ~/prod/  I want the dev version to import
/usr/lib/python2.5/site-packages/lib_dev/, and the prod version to
import usr/lib/python2.5/site-packages/lib_prod/

My first instinct was to place a .pth file in ~/dev that points to
/usr/lib/python2.5/site-packages/lib_dev, and a .pth file in ~/prod that
points to /usr/lib/python2.5/site-packages/lib_prod, but it seems that doesn't look at .pth files in the current working directory.  My
next attempt was to create a symbolic link in ~/dev called,
pointing to /usr/lib/python2.5/site-packages/lib_dev/, and a
symbolic link in ~/prod called, pointing to
/usr/lib/python2.5/site-packages/lib_prod/, but that didn't work

Can anybody suggest a way to achieve my goal?  Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list