Best way to find starting directory
frank at chagford.com
Tue Mar 19 08:26:36 CET 2013
I want to locate a file relative to the directory from which the main
program was launched.
I have found two ways of finding the starting directory -
dir = os.getcwd()
dir = os.path.dirname(__main__.__file__)
I know that the first one will return the wrong result if os.chdir() has
been executed, but I don't do that.
Apart from that, is either version preferred over the other, or is there
More information about the Python-list