Is there a Python library that packs binary data into one file?
Brian Kelley
bkelley at wi.mit.edu
Tue Apr 27 10:08:28 EDT 2004
Jacob H wrote:
> Hello all,
>
> Today I began writing a utility script that takes given binary files
> and puts them all into one datafile. My idea is to be able to access
> any binary data I want by indexing the datafile, e.g.
> wanted_image_data = datafileobj[IMAGE_DATA]. The purpose is to hide
> external image files from the user in a simple game I'm writing.
In the vein of giving a man a fish: if you are using python 2.2+
import dbhash, zlib
db = dbhash.open("foo.db", 'w')
db['hi'] = zlib.compress("my dog has fleas")
print zlib.decompress(db['hi'])
for more help
type
help(dbhash)
at the interpreter
In the vein of teaching a man to fish, read the library reference here
for a lot of python goodies:
http://python.org/doc/2.3.3/lib/
Brian
More information about the Python-list
mailing list