I am interacting with a python 2.x API written in a non-OO way, it uses module-global scope for some internal state driven stuff. It\'s needed in a context where it\'s no longer
Easiest way is to make two copies of the module and import them separately. For example, take your module thingabobber
and make two copies named thingabobber1
and thingabobber2
. Then just:
import thingabobber1, thingabobber2
If this isn't feasible, delete the module from sys.modules
after initially importing it so you get a second copy on the second import.
import sys
import thingabobber as thingabobber1
del sys.modules["thingabobber"]
import thingabobber as thingabobber2