Including binary files in a .py file; advice needed

Gary Duncan gmduncan at
Thu Jun 5 04:53:26 CEST 2003

Here's what I want to do; distribute a .py file (a GUI app) with
an embedded (binary) .GIF file (a photo of me at 1 yo ;) rather than
distribute both separately. For convenience, mainly.

If in a Unix shell script, I'd uuencode the .GIF and include the 
printable-ASCII file in it as a 'here' file. When executed the script
would 'cat' it out to e.g. a /tmp file from the main body of the script, 
then uudecode the /tmp file to revert to the original .GIF file.

I imagine in Python, one could place the uuencoded file (lines)
as a triple-quoted string, then uudecode it the .py program.

Anything better ?

The Martellibot's PIAN is silent on this ;
    fine book otherwise <0.9 wink>

- Gary

More information about the Python-list mailing list