I had a directory structure like the following for a Python project:
my_project
|_
...
dirA
|_
__init__.py
scriptA.py
dirB
|_
__init__.py
scriptB.py
...
Inside __init__.py of dirA (__init__.py of dirB is empty), I have:
import os
import glob
__all__ = [os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(os.path.abspath(__file__)) + "/*.py")]
Inside scriptB.py, I do:
from dirA import *
And the subsequent code which utilizes the imports works fine.
Then, I copied and pasted the whole project (with a different project directory name: my_project_new) in the same directory as the old one, and I start changing the code of scriptA.py in this newly duplicated directory. (Note: directory structure of my_project_new remains exactly the same as above).
After making the changes, I tried to run scriptB.py of my_project_new, and I found that it kept importing dirA from the original my_project directory, instead of the dirA in the current my_project_new directory. Why is this?
Further, I moved the original my_project folder to a different location, and tried to run scriptB.py of my_project_new again. It then failed to identify dirA altogether. What is happening now?