I am trying to find a natural mechanism to achieve what looks like 'compile-time' switching between various implementations of the same interface (same 'duck-type').
Suppose I have two classes with some factory functions:
import Number1 as Number
# choose your implementation here
Number = Number1
from Number import Number
Using wildcard-import may be easiest way to tackle it.
if use_module_1: from Number1 import * else: from Number2 import *
In all client code:
import Number # or from Number import some_name
While wildcard import is usually considered a bad practice, that's not a case here, since you actually want to pollute
Number namespace with all elements from