On Nov 22, 10:37 am, Wayne Brehaut <[EMAIL PROTECTED]> 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: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ed25388487b3ac7b Here folks fight the same problem in one way uglier than another. Iterators and whatnot are thrown at a poor li'l EOF: http://groups.google.com/group/comp.lang.python/browse_thread/thread/b09d612e99f67561 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 (extracts): 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. :) Cheers, Alexy -- http://mail.python.org/mailman/listinfo/python-list