Re: How to read one byte at a time in Python?

From: Garry Knight (garryknight_at_gmx.net)
Date: 03/13/04


Date: Sat, 13 Mar 2004 01:21:00 +0000

In message <mailman.335.1079137564.19534.python-list@python.org>, Anthony
Liu wrote:

> Java has functions that read only one byte at a time,
> do we have such a function in python?

inf = open('filename', 'r')
c = inf.read(1)

Depending on the meaning of the word 'byte' in your question, you might want
to make the file mode 'rb'.

-- 
Garry Knight
garryknight@gmx.net  ICQ 126351135
Linux registered user 182025


Relevant Pages

  • Re: Lens Algebra
    ... meaning for example, 5 could be less than or greater than 7 depending ... circular operations. ... If "inf" is the one that spoils all this fun, ...
    (sci.math)
  • Re: Why prefer != over <> for Python 3.0?
    ... and it resembles the fancy assignment statement ... When I started to learn python I came across an operator. ... operators with clear and obvious meaning. ... places (which is the reason why some languages can use the same ...
    (comp.lang.python)
  • Re: painful debugging: techniques?
    ... Perhaps not so much a trick as much as experience, ... with Python a bit, you'll find that any time you see something like ... depending on how much new code you had written before the error ... started happening could help bound your search, ...
    (comp.lang.python)
  • Re: Turn off ZeroDivisionError?
    ... invalid signals, and OverflowError would be raised anywhere that IEEE ... 754specifies raising the overflow signal. ... Python to make it possible to turn nonstop mode on or off, ...
    (comp.lang.python)
  • Re: pickle broken: cant handle NaN or Infinity under win32
    ... > representation for Python to use for NaN and Inf. ... relevant to pickle changes. ...
    (comp.lang.python)