Re: how exactly do binary files work in python?

2006-03-13 Thread Scott David Daniels
Steven D'Aprano wrote: [Generally fine stuff, I am elaborating rather than dis-agreeing.] On Sun, 12 Mar 2006 22:01:46 -0500, John Salerno wrote: Erik Max Francis wrote: You can use the struct module for converting fundamental types to a portable string representation for writing to binary

how exactly do binary files work in python?

2006-03-12 Thread John Salerno
In C#, writing to a binary file wrote the actual data types into the file (integers, etc.). Is this not how Python binary files work? I tried to write integers into a file, but the write method only takes a string argument anyway. Is there a way to actually store integers in a file, so that

Re: how exactly do binary files work in python?

2006-03-12 Thread Erik Max Francis
John Salerno wrote: In C#, writing to a binary file wrote the actual data types into the file (integers, etc.). This was inherently nonportable. Is this not how Python binary files work? I tried to write integers into a file, but the write method only takes a string argument anyway.

Re: how exactly do binary files work in python?

2006-03-12 Thread John Salerno
Erik Max Francis 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? What does a binary file do that a text file doesn't, aside from not converting the end

Re: how exactly do binary files work in python?

2006-03-12 Thread Grant Edwards
On 2006-03-13, John Salerno [EMAIL PROTECTED] 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

Re: how exactly do binary files work in python?

2006-03-12 Thread Alex Martelli
Grant Edwards [EMAIL PROTECTED] wrote: ... 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. I believe that a control-Z (ord(26)) in a file that's being read

Re: how exactly do binary files work in python?

2006-03-12 Thread Steven D'Aprano
On Sun, 12 Mar 2006 22:01:46 -0500, John Salerno wrote: Erik Max Francis 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? What does a binary file do

Re: how exactly do binary files work in python?

2006-03-12 Thread Grant Edwards
On 2006-03-13, Alex Martelli [EMAIL PROTECTED] wrote: Grant Edwards [EMAIL PROTECTED] wrote: ... 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. I believe