Directory of current file

Jeff Bauer jbauer at rubic.com
Thu Apr 22 07:45:22 EDT 1999


David Ascher wrote:
> 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]

David, what are the advantages over this?

  _thisDir = os.path.split(sys.argv[0])[0]

Jeff Bauer
Rubicon, Inc.




More information about the Python-list mailing list