Reputation: 1302
I'm setting up a new algorithm and I want to share it on another computer. How can I set paths with only the folder name, for example.
I've tried to use the function os.chdir(path), but I don't achieve to reach my folder when I'm not using a 'root path' like C:/../../folder.
os.chdir(../folder_name)
Upvotes: 0
Views: 496
Reputation: 6662
By doing os.chdir(../folder_name)
, you are referring to the parent dir of the current directory.
You probably are looking for the os.chdir(./folder_name)
, with one dot? This is the current directory, where your script stands.
More here: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
Update: After clarification in the comments, you want to refer to folder_name
from one of its subfolder (/folder_name/library
). Then it is indeed ..
that you should use, but ..
only:
os.chdir(..)
Upvotes: 1