import issues python3.4

Heli hemla21 at gmail.com
Wed Nov 8 10:58:40 EST 2017


Dear all, 

I have a software code that is written in python and has a structure like this. 

package/
    run_my_gui.py    #gui

    sub_package/
    main.py
    sub_sub_package/
        __init__.py
          A.py
          B.py
          C.py


All the imports in main.py are absolute and look like below: 

(1) from package.sub_package.sub_sub_package import A

The issue is I have an external script that tests main.py.  I do not want to manually edit all import statements in my code to look like below:

(2) from sub_sub_package import A

Is there anyway I can run my external script without changing the absolute path from (1) to (2) in my code. 

I use subprocess.call to run main.py within my external script and it gets few arguments to run. 

Thanks a lot in advance for your replies,  




More information about the Python-list mailing list