open() in binary vs. text mode

Jp Calderone exarkun at intarweb.us
Thu Mar 20 13:57:19 EST 2003


On Thu, Mar 20, 2003 at 10:03:17AM -0800, Bob Roberts wrote:
> I just finished tracking down a cross-platorm bug.  The problem was
> that I didn't open() a file in binary ("rb") mode.  What exactly does
> the binary flag do on windows?  What is it's purpose?

  In text mode, \n's written to disk are translated to \r\n's before they
are actually written.  This translation is reversed when reading.  Binary
files have no translations performed on them.

  Jp

-- 
Examinations are formidable even to the best prepared, for
even the greatest fool may ask more the the wisest man can answer.
                -- C.C. Colton
-- 
 up 13:58, 4 users, load average: 0.55, 0.57, 0.47





More information about the Python-list mailing list