braver deliverable at gmail.com
Thu Nov 22 10:22:39 CET 2007

On Nov 22, 10:37 am, Wayne Brehaut <wbreh... at mcsnet.ca> wrote:

> As others have already pointed out, "because it's seldom necessary in Python".

You know what?  I've read this many times, and it's a lot of self-
congratulation.  There's lot of things which can be useful in Python.

This lack of EOF is inconvenient, there's nothing "Python way" about
it, as a simple search on "EOF" or "eof" in this group demonstrates.
Just a few threads:


Here folks fight the same problem in one way uglier than another.
Iterators and whatnot are thrown at a poor li'l EOF:


The recurrence of the question simply shows Python lacks an f.eof()
method.  That's all!

Why do we may need it?  The last thread shows clearly -- because the
last line processing is often a special case.  After I couldn't find
the f.eof() in Python docs, I've quickly changed the logic to this

filesize = os.stat(filename)[6]
cur_size = 0

def eof():
	return cur_size == filesize

def add_line(line):
	self.cur_size += len(line)
	if eof():
		print >>sys.stderr, "* * * eof * * *"

Basically, it allows me to write what I want, and it's natural to ask
for eof() in this case -- and for a language to provide it.  Ruby has
all iterators-schmiterators you want and a kitchen sink, yet provides
the said eof() without much fuss and 100 threads on c.l.*.  :)

> "Python is not Ruby."

Both Python and Ruby happily agree here:
>> "Python" == "Ruby"
=> false
In [11]: "Python" == "Ruby"
Out[11]: False

There's nothing special about Python except indentation, which gets
screwed up between editors all the time.  (It's much easier to flip-
flop between TextMate and Emacs with Ruby than with Python, without
setting your tabs and spaces pedantically.)  It's faster than Ruby,
otherwise they're similar.  When Ruby X.Y gets faster, it'll be a
tough call to between 'em.  I use Python to accomplish things I know
how, with algorithms which work and proven control logic, so this is
reasonable to ask about certain control flow equivalents.  And
comparisons will always be good.  :)


More information about the Python-list mailing list