how exactly do binary files work in python?

Grant Edwards grante at visi.com
Sun Mar 12 22:19:33 EST 2006


On 2006-03-13, John Salerno <johnjsal at NOSPAMgmail.com> wrote:

>> You can use the struct module for converting fundamental types
>> to a portable string representation for writing to binary
>> files.
>
> But if it's a string, why not just use a text file?

Because string != text.

In Python a "string" is just an arbitrary length chunk of bytes.

> What does a binary file do that a text file doesn't, aside
> from not converting the end of line characters?

Nothing.  It's the end-of-line conversion that can break binary
data.

-- 
Grant Edwards
grante at visi.com




More information about the Python-list mailing list