Say there is a folder, ‘/home/user/temp/a40bd22344’. The name is completely random and changes in every iteration. I need to be able to import this folder in Python using a fixed name, say ‘project’. I know I can add this folder to sys.path to enable import lookup, but is there a way to replace ‘a40bd22344’ with ‘project’?
Maybe some clever hacks in init.py?
Added:
It needs to be global – that is, other scripts loading ‘project’ via the standard:
import project
Have to work properly, loading a40bd22344 instead.
You first import it with import:
Then you make sure that this module gets known to Python as
project:After this, anything importing project in the current Python session will get the original module
This will work also for sub-modules: if you have a foobar.py in the same location you’ll get
Addendum. Here’s what I’m running: