Python module shared between multiple products
- by MattyW
I'm working on a python class that is being shared between two products. 90% of the functionality applies to both products. For the 10% that's different the code is littered with this kind of thing:
#Start of file
project = 'B'
#Some line of code
if project == 'A':
import moduleA
elif project == 'B':
import moduleB
#Many lines of code
if project == 'A':
print moduleA.doA(2)
elif project == 'B':
print moduleB.doB(2)
This doesn't seem very elegant or very readable, has anyone encountered this sort of thing before? Are there better ways of doing it?