Jerry LeVan wrote: >Hi, > >I am porting one of my Tcl/Tk apps to Python and am having >a bit of a problem with one detail. > >The structure of the app is that the main program >sits in a folder and local resources live in a >subFolder named Resources. > >I can easily pick up modules living in Resources, but >I can't see how to find pure "data" files living in the >the Resources folder. > >In Tcl I can find the path to a script with the info command. > >I tried looking at "sys.path" but the "current directory" seems >to be specified by '' ( instead of the the full path name). > >Is there anyway I can discover the pathname of an running >python script? > > You can do something like
def pathToExecutable(): dir, file = os.path.split(sys.executable) if file == "my application name": return dir dir, file = os.path.split(sys.argv[0]) return dir If you want a more general version to handle any application name, then you need to deal with determining whether the app is being run from a script or has been frozen (with py2exe or py2app or freeze or ...) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.7.0/346 - Release Date: 23/05/2006 _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig