Python module shared between multiple products

Posted by MattyW on Stack Overflow See other posts from Stack Overflow or by MattyW
Published on 2010-05-12T23:20:56Z Indexed on 2010/05/12 23:24 UTC
Read the original article Hit count: 110

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about modules