F
Frank Millman
Hi all
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 -
1.
import os
dir = os.getcwd()
2.
import os.path
import __main__
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
another way?
Thanks
Frank Millman
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 -
1.
import os
dir = os.getcwd()
2.
import os.path
import __main__
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
another way?
Thanks
Frank Millman