Link to home
Start Free TrialLog in
Avatar of templeavenue
templeavenue

asked on

how to read byte

what functions should I use to read byte by byte from binary files? I looked up and found that the read() functions. but it returns the whole files in binary.  But I like to read byte by byte.  Thanks in advance.

Kelvin
Avatar of ramrom
ramrom
Flag of United States of America image

From the Python Library Reference under 2.3.9 File Objects:
"read( [size])
Read at most size bytes from the file "

Nuf said?

But before you jump, are you clear on what you want do accomplish. Reading a file byte by byte is probably less efficient than reading, say, a line then accessing each byte in the line.

So what is your goal?
Avatar of templeavenue
templeavenue

ASKER

I want to make comparions byte(possiblly bits) between the byte read from the file and the reference byte(which I don't need to read from any file).  
OK. Well I think you have the information you need. Any questions?
oh...i still haven't figure out how to read byte from file.  Can you please explain?
ASKER CERTIFIED SOLUTION
Avatar of ramrom
ramrom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm glad I could help. I am confused by getting a grade of C. Please note the EE guidelines for grading:

    *  A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

    * B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

    * C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

Basedd on that I'd have given a grade of A. Please help me understand how you came up with a different result.

I am also confused in that your original question was "what functions should I use to read byte by byte" and I answered that in my first comment.
well..I think I agree with you. When I graded that I just think "whatever".  Sorry, based on the questions I asked, I should have graded as A.  I am willing to change the grade, but I don't know how.. Again. sorry...you have been helped... and thanks