Converting Hex to decimal

Miki Tebeka miki.tebeka at
Wed Jun 2 11:25:48 CEST 2004

Hello Dean,

> Each hex character is 8 bits. I would like to convert one byte at the
> time and pipe the converted data into a new file.
This is not tested but should be in the lines of what you're trying to

from array import array
a = array("B")
a.fromstring(open("input_file", "rb").read()) # Read all file
out = open("output_file", "wb")
for bit in a:
    new_bit = convert(bit)

Miki Tebeka <miki.tebeka at>
The only difference between children and adults is the price of the toys.

More information about the Python-list mailing list