hdante at gmail.com hdante at gmail.com
Sat Nov 24 05:00:08 CET 2007

On Nov 22, 1:17 pm, braver <delivera... at gmail.com> wrote:
> Ruby has iterators and generators too, but it also has my good ol'
> f.eof().  I challenge the assumption here of some majectically Python-

 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). I find it ok that ruby
subverts the good old eof, but it's unaceptable for python to do so.

 Besides, it's probable that your code could work with the following

def try_read(f):
	line = f.readline()
	eof = (line == '')
	return (line, eof)
def xor(a, b):
	return a and not b or b and not a

count = 0
while True:
	next_line, eof = try_read(f)
	if not eof:
		count += 1
		line = next_line
	if xor(count % 1000 == 0, eof):
		summarize(count, line)
	if eof:

> wayist spirit forbidding Python to have f.eof(), while Ruby, which has
> all the same features, has it.  Saying "it's not the Python way" is
> not a valid argument.

 Yes, it is.

> Cheers,
> Alexy

More information about the Python-list mailing list