Developing a Package with Sub Packages

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Feb 18 09:23:42 CET 2008


En Sun, 17 Feb 2008 22:34:27 -0200, Josh English  
<joshua.r.english at gmail.com> escribi�:

> Here's what I think is happening: IMS/__init__.py uses os.getcwd() to
> establish the path to the data folder and the files inside of it. When
> I run StoryCreator, os.getcwd() returns the story folder.
> If I'm right, how can I get the IMS/__init__.py module to use relative
> paths to its own module, and not the current working directory the os
> module provides?

Use the module's own __file__ attribute:
my_path = os.path.abspath(os.path.dirname(__file__))

-- 
Gabriel Genellina




More information about the Python-list mailing list