Locating Relative Resource Files

Don Garrett garrett at bgb.cc
Thu Sep 13 17:11:15 EDT 2001


  Thanks! 

  I feel almost embarrassed for not thinking of this, but
working in Windows (instead of Unix) throws me off a beat. This
is solving my problem perfectly!

Gordon McMillan wrote:
> 
> [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

--
Don Garrett                                   http://www.bgb.cc/garrett/
BGB Consulting                                            garrett at bgb.cc



More information about the Python-list mailing list