eof

MonkeeSage MonkeeSage at gmail.com
Fri Nov 23 23:24:30 EST 2007


On Nov 23, 10:00 pm, "hda... at gmail.com" <hda... at gmail.com> wrote:

>  Ruby doesn't have the good ol' eof. Good old eof tests a single flag
> and requires a pre read(). Ruby's eof blocks and does buffering (and
> this is a very strong technical statement).

Actually, to be a bit more technical, IO#eof acts like standard C eof
for File objects, it only blocks / requires a previous read() on
character devices and pipes and such. For files, it's the same as
checking the absolute position of the file stream: f.tell ==
File.size(f.path).

Of course, the same can be done in python quite easily (and probably
better implemented):

f.tell() == os.stat(f.name).st_size

I don't honestly see what the big deal is about including or excluding
an eof function / method in python. If you need it, it is easy to
implement, and like yourself and others have shown, you usually don't
need it.

Regards,
Jordan



More information about the Python-list mailing list