Is there a way to use the Open() function with an absolute path? I would like to open any file wherever it is on the disk, but Open() sets it's working directory to the location of the file by default, can I change this?
1 Answer
If you are on linux you would need to add a / to the beginning of the path, for example to access /tmp/someFile.txt you would do open("/tmp/someFile.Txt"). This works because / references the root.
On windows (this has not been tested) i before you would do open("C:/someFile.txt").
The docs for the open function can be found at: https://docs.python.org/3/library/functions.html#open
Open()function are you talking about? Do you mean the standardopen()function?open(), the working directory is irrelevant. It is only used to turn a provided relative path into an absolute path.