I already know this will be (wrongly, in my opinion) labelled as duplicate because of this or this, which I've already looked at.
However my problem is different, and cannot be solved with the answers found there.
So I have a python script in C:\Users\Me\Desktop\My folders\Projects\My stuff\Last Folder\some_file.py
. From this I want to import a file in the same directory, i.e. inside Last Folder
, for this I just use import file
.
However, then I have a file in C:\Users\Me\Desktop\My Other Folder\My Other Projects\ My Other Stuff\other_file.py
. As you can see the folders have spaces.
Now in the second of the two links above we are told how to import a python file with spaces in the name, a python file, not a folder!
In the second link, the user wants to just open a file using os.
I instead want to import it. How do I do it? When I try
import Users.Me.Desktop.My Other Folder.My Other Projects.My Other Stuff.other_file.py
it says "invalid syntax" because of the spaces. How can I solve this?