Re: Checking for EOF in stream

2007-02-27 Thread kousue
On Feb 19, 6:58 pm, GiBo <[EMAIL PROTECTED]> wrote: > Hi! > > Classic situation - I have to process an input stream of unknown length > until a I reach its end (EOF, End Of File). How do I check for EOF? The > input stream can be anything from opened file through sys.stdin to a > network socket. An

Re: Checking for EOF in stream

2007-02-20 Thread Nathan
On 2/19/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Mon, 19 Feb 2007 21:50:11 -0300, GiBo <[EMAIL PROTECTED]> escribió: > > > Grant Edwards wrote: > >> On 2007-02-19, GiBo <[EMAIL PROTECTED]> wrote: > >>> > >>> Classic situation - I have to process an input stream of unknown length > >>>

Re: Checking for EOF in stream

2007-02-20 Thread Nathan
On 2/20/07, Nathan <[EMAIL PROTECTED]> wrote: > On 2/19/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > En Mon, 19 Feb 2007 21:50:11 -0300, GiBo <[EMAIL PROTECTED]> escribió: > > > > > Grant Edwards wrote: > > >> On 2007-02-19, GiBo <[EMAIL PROTECTED]> wrote: > > >>> > > >>> Classic situation

Re: Checking for EOF in stream

2007-02-19 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > So this is the way to check for EOF. If you don't like how it was spelled, > try this: > >if data=="": break How about: if not data: break ? ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking for EOF in stream

2007-02-19 Thread Grant Edwards
On 2007-02-20, GiBo <[EMAIL PROTECTED]> wrote: >>> stream = sys.stdin >>> while True: >>> data = stream.read(1024) >> if len(data) == 0: >> break #EOF >>> process_data(data) > > Right, not a big difference though. Isn't there a cleaner / > more intuitive way? A file is at E

Re: New-style classes (was Re: Checking for EOF in stream)

2007-02-19 Thread Steven Bethard
GiBo wrote: > One more question - is it likely that StringIO will be turned into > new-style class in the future? The reason I ask is whether I should try > to deal with detection of new-/old-style classes or take the > old-styleness for granted and set in stone instead. In Python 3.0, everything

Re: New-style classes (was Re: Checking for EOF in stream)

2007-02-19 Thread GiBo
Gabriel Genellina wrote: > En Mon, 19 Feb 2007 22:30:59 -0300, GiBo <[EMAIL PROTECTED]> escribió: > >> Is there a reason why some classes distributed with Python 2.5 are not >> new-style classes? For instance StringIO is apparently "old-style" class >> i.e. not inherited from "object". Can I someh

Re: Checking for EOF in stream

2007-02-19 Thread Gabriel Genellina
En Mon, 19 Feb 2007 21:50:11 -0300, GiBo <[EMAIL PROTECTED]> escribió: > Grant Edwards wrote: >> On 2007-02-19, GiBo <[EMAIL PROTECTED]> wrote: >>> >>> Classic situation - I have to process an input stream of unknown length >>> until a I reach its end (EOF, End Of File). How do I check for EOF? Th

Re: New-style classes (was Re: Checking for EOF in stream)

2007-02-19 Thread Gabriel Genellina
En Mon, 19 Feb 2007 22:30:59 -0300, GiBo <[EMAIL PROTECTED]> escribió: > Is there a reason why some classes distributed with Python 2.5 are not > new-style classes? For instance StringIO is apparently "old-style" class > i.e. not inherited from "object". Can I somehow turn an existing > old-style

Re: Checking for EOF in stream

2007-02-19 Thread GiBo
Grant Edwards wrote: > On 2007-02-19, GiBo <[EMAIL PROTECTED]> wrote: >> Hi! >> >> Classic situation - I have to process an input stream of unknown length >> until a I reach its end (EOF, End Of File). How do I check for EOF? The >> input stream can be anything from opened file through sys.stdin to

New-style classes (was Re: Checking for EOF in stream)

2007-02-19 Thread GiBo
GiBo wrote: > Hi! > > Classic situation - I have to process an input stream of unknown length > until a I reach its end (EOF, End Of File). How do I check for EOF? > [...] > I'd better like something like: > > while not stream.eof(): > ... Is there a reason why some classes distributed wi

Re: Checking for EOF in stream

2007-02-19 Thread Grant Edwards
On 2007-02-19, GiBo <[EMAIL PROTECTED]> wrote: > Hi! > > Classic situation - I have to process an input stream of unknown length > until a I reach its end (EOF, End Of File). How do I check for EOF? The > input stream can be anything from opened file through sys.stdin to a > network socket. And it'

Checking for EOF in stream

2007-02-19 Thread GiBo
Hi! Classic situation - I have to process an input stream of unknown length until a I reach its end (EOF, End Of File). How do I check for EOF? The input stream can be anything from opened file through sys.stdin to a network socket. And it's binary and potentially huge (gigabytes), thus "for line