I would like to do something like this in one source file, QT.py:
import sys import PyQt4 sys.modules[\"Qt\"] = PyQt4
Then import this fil
You can conditionally import libraries. Here is a bit of a hacky example, where you check for a command-line argument of "PyQt4":
import sys if sys.argv[-1] == 'PyQt4': import PyQt4 sys.modules["Qt"] = PyQt4 else: import Qt from Qt.QtCore import *