Directory of current file

David Ascher da at ski.org
Thu Apr 22 01:10:28 EDT 1999


Tip:  To find out the directory of the currently executing program, use:

import sys, os
if __name__ == '__main__':
    _thisDir = ''
else:
    _thisDir = os.path.split(sys.modules[__name__].__file__)[0]

(note that this is a relative path).

--david







More information about the Python-list mailing list