Message214195
This is my first post on bugs.python.org. I hope I abide to the rules. It was suggested to me on stackoverflow.com, that I request an enhancement to the module fileinput here:
http://stackoverflow.com/questions/22510123/reading-individual-bytes-of-multiple-binary-files-using-the-python-module-filein
I can read the first byte of a binary file like this:
with open(my_binary_file,'rb') as f:
f.read(1)
But when I run this code:
import fileinput
with fileinput.FileInput(my_binary_file,'rb') as f:
f.read(1)
then I get this error:
AttributeError: 'FileInput' object has no attribute 'read'
I would like to propose an enhancement to fileinput, which makes it possible to read binary files byte by byte.
I posted this solution to my problem:
def process_binary_files(list_of_binary_files):
for file in list_of_binary_files:
with open(file,'rb') as f:
yield f.read(1)
return
list_of_binary_files = ['f1', 'f2']
generate_byte = process_binary_files(list_of_binary_files)
byte = next(generate_byte) |
|
Date |
User |
Action |
Args |
2014-03-20 09:39:18 | Tommy.Carstensen | set | recipients:
+ Tommy.Carstensen |
2014-03-20 09:39:18 | Tommy.Carstensen | set | messageid: <1395308358.24.0.394354098821.issue20992@psf.upfronthosting.co.za> |
2014-03-20 09:39:18 | Tommy.Carstensen | link | issue20992 messages |
2014-03-20 09:39:17 | Tommy.Carstensen | create | |
|