Lets say I have a symlink in directory A which points to a python file in directory B. When I execute the symlink, the python file in directory B successfully executes (it also uses other python files in its directory). However, there are a lot of issues with using symlinks in terms of operating systems so I would like to emulate this using plain python.
Here is what I have so far.
File in directory A:
import os
import sys
sys.path.append("DirectoryB") # File_B is importable now
os.chdir("DirectoryB") # Change dir so File_B's imports work
import File_B # Run File_B
So now when the directory A file is run - file B will successfully be run as if the file in directory A was a symlink.
Is there anything wrong/missing with this approach? And is there a way to do it better?