opening a file using a relative path from a subclass in a package

spike grobstein spike.666 at gmail.com
Wed Dec 7 14:54:39 EST 2005


So, I've got this project I'm working on where the app defines various
classes that are subclassed by module packages that act like plugins...

I'd like the packages to define a file path for supporting files
(graphics, etc) that are stored inside the package. The problem is that
the superclass's definition (stored elsewhere) has all of the code for
actually opening the files, so when I use the
os.path.dirname(os.path.abspath(__file__)) trick, it's finding the
superclass, not the package's path.

is this possible? or do I have to add code to each subclassing package
to calculate the absolute path of it and pass that as a variable?

I'd rather not have to repeat myself for each package that I make, and
I've got a feeling that I'm missing something really obvious.

thanks in advance!


...spike




More information about the Python-list mailing list