Locating Relative Resource Files

Gordon McMillan gmcm at hypernet.com
Wed Sep 12 17:30:39 EDT 2001


[posted and mailed]

Don Garrett wrote:

>   Is there some way to determine the location of the file from which
> the currently executing source was loaded? Or the file/directory of
> the initial python script?

os.path.dirname(sys.argv[0]) should do it (although it may be '', 
meaning os.getcwd() is the script's directory).

- Gordon



More information about the Python-list mailing list