2.2 <-> 2.3 surprise

Michael Hudson mwh at python.net
Fri Jun 4 09:58:54 CEST 2004


Roman Suzi <rnd at onego.ru> writes:

> On Mon, 31 May 2004, Shalabh Chaturvedi wrote:
> 
> >Roman Suzi wrote:
> >
> >> Hi!
> >>
> >> I really like python 2.3 but sometimes I write for 2.2 too.
> >>
> >> New cool feature of doing:
> >>
> >> f = open('file')
> >> for line in f:
> >>   do_something(line)
> >>
> >> works strange in 2.2: I can't just quit first loop and do:
> >>
> >> for line in f:
> >>   do_some_more(line)
> >>
> >> (I as skipping message header by first loop and processing body
> >> the the second).
> >>
> >> In 2.3 it works as intended! Of course, simple refacture made it one loop...
> >>
> >>
> >>
> >> Sincerely yours, Roman Suzi
> >
> >This is probably the following change as described in
> >http://www.python.org/2.3/highlights.html
> >
> >"File objects are now their own iterators. This makes multiple
> >interrupted iterations over the same file more reliable."
> 
> Hmmm... Such gradual changes IMHO are worse than just adding something
> at once. The problem is I was getting no warnings that something is wrong.
> In some big project this could break a lot.

Are you arguing that the 2.2 behaviour should have been retained? If
so, you're wrong :-)

Cheers,
mwh

-- 
  This makes it possible to pass complex object hierarchies to
  a C coder who thinks computer science has made no worthwhile
  advancements since the invention of the pointer.
                                       -- Gordon McMillan, 30 Jul 1998



More information about the Python-list mailing list