eof

Hendrik van Rooyen mail at microcorp.co.za
Thu Nov 22 03:18:38 EST 2007


"braver" <deliverable at gmail.com> wrote:


> Well folks compare scripting languages all the time, and surely Ruby
> is closer to Python than C++.  Since Ruby can do f.eof, which is
> easily found in its references, and Python can't, or its EOF can't
> easily be found -- the one *equivalent* to a semantically clear
> Ruby's, or Pascal's IIRC, f.eof -- something's missing here...
> 
> Why do I have to count sizes of lines read and compare it to some
> filesize or do other weird tricks just to see, in a way not changing
> my input stream, whether it's at the, well, EOF?

The man has a valid point - 

In general, Python allows you, for an object f,
to write:

f.SomethingNew = 'Whatever the hell you like'

However, when f is a builtin file object,
it barfs on an AttributeError.

So he can't even help himself by setting his
own EOF attribute to False initially, and
to True when he sees an empty string.

Is there a reason for this Bondage style?

- Hendrik




More information about the Python-list mailing list