include files with a package

John Hunter jdhunter at nitace.bsd.uchicago.edu
Sun May 27 22:56:10 CEST 2001


I have some files that I want to include with a package of modules I
am working on.  These are xlst stylesheets.  From within the module,
say in the __init__ statement, I would like to do 

class Foo:
   def __init__(self):
       self_.fh = open(the_path_to_foo + "sheet.xsl")

Is there a way to figure out where a package is installed from within
the __init__ statement.  I know I can include the style sheet in the
package literally in a """ environment, but I find this more difficult
to maintain.

Is this a bad idea to want to do this?

I suppose I could iterate over the module search path and look for the
file, but that doesn't strike me as very elegant.

Suggestions?
Thanks,
John Hunter 



More information about the Python-list mailing list