I have a script that loads an image from its directory, and I want to be able to import that script from any file, with this script still being able to find its image. Probably clearer that way:
A/file1.pyimages/img.png
B/file2.py
In file1.py:
image = load_img("images/img.png")
In file2.py:
import file1
# here, I expect to be able to use file1.image
But in file2, the relative path is relative to B/ directory, and images/img.png is therefore not found.
How can I have my image variable available, no matter from where I import file1.py without writing an absolute path here ? What's the best practice to do so ?
Thanks in advance for any help or advice.
file1". I made 2 directories as an example, but real case is more complex (like a library that could be imported from any project).