Too many return-statements = bad style?

Terry Reedy tjreedy at udel.edu
Wed Jul 14 23:53:57 CEST 2004


[snip 5 ways to process file with while loops]

"Michael Geary" <Mike at Geary.com> wrote in message
news:10fb934hkq76c97 at corp.supernews.com...
>
> File.open(...).each do |line|
>     [ process line from file ]
> end

I presume this is equivalent to Python's

for line in file(...):
  process(line)

while is the proper way in Python also.  With iterators, for loops make
many awkward while loops obsolete.

Terry J. Reedy






More information about the Python-list mailing list