There is also a convenience function for this in Zope:
from Globals import package_home
here = package_home(globals())
On Tue, 2004-03-09 at 14:16, Fred Drake wrote:
> On Tuesday 09 March 2004 01:58 pm, Ian Beatty wrote:
> > This has to be an easy one.
> Good, I'll take it. ;-)
> > From within my Python-based product's code, how do I get access to the
> > product's directory on the filesystem? os.getcwd() seems to provide the
> > working directory of the shell used to launch Zope, at least when running
> > in debug mode.
> This isn't actually Zope specific; you can easily get the directory a module
> lives in using this:
> import os
> here = os.path.dirname(os.path.abspath(__file__))
> The variable "here" will hold a string with an absolute path to the directory
> containing the source file for your module (named by __file__). The call to
> os.path.abspath() isn't strictly necessary, but protects against future calls
> to os.chdir() (though not past calls!) in case the module was loaded from
> directory named by a relative directory on sys.path.
> You can do this just once at module scope; there's no need to recompute this
> each time you need it.
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -