Thanks, didn't realize it would be quite so easy.
----- Original Message ----- From: "Matt Nordhoff" <[EMAIL PROTECTED]> To: "ron.longo" <[EMAIL PROTECTED]> Cc: <python-list@python.org> Sent: Tuesday, December 11, 2007 2:50 PM Subject: Re: finding dir of main .py file > ron.longo wrote: >> Nope, maybe I'm not explaining myself well. >> >> When I do os.getenv('HOME') I get back None. >> >> According to the docs, 'HOME' is the user's home directory on some >> platforms. Which is not what I want. >> >> What I want is the directory in which an application's main .py file >> resides. That is, when I type: python MyApp.py, I want to know in which >> directory does MyApp.py reside? > > Shane is right. > >>>> print __file__ > >>>> print modulename.__file__ > > Just call os.path.dirname() on __file__ to get the directory. > -- > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list