Re: Unpacking byte strings from a file of unknown size

2008-10-28 Thread Mark
> this code python interprets as: > > data = myfile.read(10) > for chunk in data: > . > Aha - now that you put it that way it makes sense. And thanks to all who replied - I'll try out the other suggestions too. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Unpacking byte strings from a file of unknown size

2008-10-28 Thread Scott David Daniels
Mark wrote: Thanks I tested your solution and that works. One of the things that didn't work was for chunk in myfile.read(10): info1, info2, info3 = struct.unpack(' this code python interprets as: data = myfile.read(10) for chunk in data: . --Scott David Daniels [EMAIL PR

Re: Unpacking byte strings from a file of unknown size

2008-10-28 Thread Mark
Thanks I tested your solution and that works. One of the things that didn't work was for chunk in myfile.read(10): info1, info2, info3 = struct.unpack('http://mail.python.org/mailman/listinfo/python-list

Re: Unpacking byte strings from a file of unknown size

2008-10-27 Thread Terry Reedy
Mark wrote: Hi; I'm trying to use the struct.unpack to extract an int, int, char struct info from a file. I'm more accustomed to the file.readlines which works well in a 'for' construct (ending loop after reaching EOF). You do not need .readlines to iterate through a file by lines. for line

Re: Unpacking byte strings from a file of unknown size

2008-10-27 Thread Gabriel Genellina
En Mon, 27 Oct 2008 19:03:37 -0200, Steven Clark <[EMAIL PROTECTED]> escribió: On Mon, Oct 27, 2008 at 4:29 PM, Mark <[EMAIL PROTECTED]> wrote: Hi; I'm trying to use the struct.unpack to extract an int, int, char struct info from a file. I'm more accustomed to the file.readlines which works

Re: Unpacking byte strings from a file of unknown size

2008-10-27 Thread Steven Clark
On Mon, Oct 27, 2008 at 4:29 PM, Mark <[EMAIL PROTECTED]> wrote: > Hi; > > I'm trying to use the struct.unpack to extract an int, int, char > struct info from a file. I'm more accustomed to the file.readlines > which works well in a 'for' construct (ending loop after reaching > EOF). > > # This do

Unpacking byte strings from a file of unknown size

2008-10-27 Thread Mark
Hi; I'm trying to use the struct.unpack to extract an int, int, char struct info from a file. I'm more accustomed to the file.readlines which works well in a 'for' construct (ending loop after reaching EOF). # This does OK at fetching one 10-byte string at a time: # (4, 4, 2 ascii chars represen