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 EOF when read() returns ''.  The above is the
cleanest, simplest, most direct way to do what you specified.
Everybody does it that way, and everybody recognizes what's
being done.

It's also the "standard, Pythonic" way to do it.

> Like using some wrapper objects around the streams or
> something?

You can do that, but then you're mostly just obfuscating
things.

-- 
Grant Edwards                   grante             Yow!  Vote for ME
                                  at               -- I'm well-tapered,
                               visi.com            half-cocked, ill-conceived
                                                   and TAX-DEFERRED!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to