Foriegn contents in Python Packages...

Diez B. Roggisch deets at nospam.web.de
Fri Apr 28 06:15:47 EDT 2006


redefined.horizons at gmail.com wrote:

> Is it possible to store "non-python" files in a directory that serves
> as a Python Package? (Like an image file or an XML file.)
> 
> Is this allowed for sub-directories that are not Python Packages? In
> other words, can I have a Python Package that contains other Python
> Packages and also folders that aren't Python Packages?

Yes. And the __file__-attribute of an imported module gives you the location
in the filesystem, so that you can access the contents in a path-agnostic
way.

AFAIK there is even some builtin stuff in setuptools to handle data files -
go google :)

Diez



More information about the Python-list mailing list