I wrote and maintain an AMR (automated meter reading) store/transfer system. The system is implemented in Python, and has both command line and Django components, which share Python modules. Django is using Python 2.6.6, and the command line version is using 2.7.3.
Last Spring, I had to use pysftp and wound up breaking the web application. There is no pysftp installed for Python 2.6.6.
Eventually, this server is going to be rebuilt, but, until it is, I restored the web site using a bit of a kludge, by performing this workaround. The web site (Django) component does not use pysftp.
It’s funny that until you try something, you don’t know if it will work. Here is the workaround:
import sys import os if our_python_version >= (2,7,3): import pysftp
Since Django was built using Python 2.6.6 and no Django modules use sftp this is a good workaround, until I can rebuild this server.
This is what I like about these more modern languages, like Python, Clojure, and even languages like Perl. You can interdict during a module load.