web hosting and development forums
Web Design and Development Forums Archive


Index - Python programming forum

how to embed a binary data into my python program


Post reply

I want to embed a small amount of binary data into my python program. what's the best way to do this?
froomzer, Binary data?
Something that can be expressed as ascii
froomzer, why embed, why not use a separate file?
froomzer, Probably to create a .bin file and then read from it I meant to ask what does the binary data consist of?
It would be best if it was embeded because I only want to distribute only one file
froomzer, you could store it as base64 encoded, or as digits, and convert it inside the file
Base64 sounds good
There's base64 support in the standard library notw afaik
Do I just use a unicode string and encode/decode it with this?
froomzer, you don't need unicode, it's 7-bit
But unicode strings have these nice encode/decode functions
froomzer, they won't deal with base64
Or is there another method for encoding to base64
froomzer, base64.decodestring, base64.encodestring
Ok, I'll play a bit with the different possibilities and see which one works best. thanks
froomzer, bindata = base64.decodestring("""...""")
Ok, thats fine. thank you!




Dubai Forum | Paris Forum | Webmaster Forum | Vegan Forum | Brisbane Forum | 3D Forum | Jobs in Dubai | Jobs in London | London UK Classifieds
Archive script by RedHo.com