How to maintain different version of a python module?
Question: I have this core python module we use in our facility called mfxLib. I need to
be able to keep different version of this module without breaking all the
other modules/plugin that are importing this module.

My solution was keep a duplicate of my module by renaming them mfxLib01 and
mfxLib02 then to replace the original mfxLib module with an empty module
containing only a `__init__.py` file that import the latest version.

    
    
    # content of mfxLib.__init__.py
    from mfxLib02 import *
    

This seems logical and seems to work but I was wondering if there was a common
practice for doing this? guidelines to follow? etc

Thanks


Answer: You can import a module _as_ another name. Commonly people use this to save
typing in a long module name, for example:

    
    
    import numpy as np
    np.array([1,2,3,4])
    

Hence you could do:

    
    
    import mfxLib01 as mfxLib
    

or

    
    
    import mfxLib02 as mfxLib
    

then your code uses mfxLib everywhere.

That might help...

