Gabriel Genellina wrote:
For those read-only resources I'd use pkgutil.get_data (instead of
manually parsing __file__):
http://docs.python.org/library/pkgutil.html#pkgutil.get_data
It's easier to manage when someone later decide to install the package as
an egg file, or distribute it using py2exe. Quoting the documentation:
"""The function returns a binary string that is the contents of the
specified resource.
For packages located in the filesystem, which have already been imported,
this is the rough equivalent of:
d = os.path.dirname(sys.modules[package].__file__)
data = open(os.path.join(d, resource), 'rb').read()
return data
"""
Thanks Gabriel, I hadn't come across get_data() yet.
DaveA
--
http://mail.python.org/mailman/listinfo/python-list