Re: 2.2 <-> 2.3 surprise

Discussion in 'Python' started by Roman Suzi, Jun 2, 2004.

  1. Roman Suzi

    Roman Suzi Guest

    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.

    >Something that *might* work in both 2.2 and 2.3 using multiple loops is
    >(not tested):
    >
    >f = iter(open('file'))
    >
    >...and then use f as before.
    >
    >--
    >Shalabh
    >
    >
    >
    >


    Sincerely yours, Roman Suzi
    --
    =\= My AI powered by GNU/Linux RedHat 7.3
     
    Roman Suzi, Jun 2, 2004
    #1
    1. Advertising

  2. Roman Suzi <> 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
     
    Michael Hudson, Jun 4, 2004
    #2
    1. Advertising

  3. Roman Suzi

    Roman Suzi Guest

    On Fri, 4 Jun 2004, Michael Hudson wrote:

    >Roman Suzi <> 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 :)

    ..
    No. But I think it was too early for 2.2 to have the feature.
    It's like having positive number addition in a version 0.1
    and fully capable addition in 0.2.

    >Cheers,
    >mwh
    >
    >


    Sincerely yours, Roman Suzi
    --
    =\= My AI powered by GNU/Linux RedHat 7.3
     
    Roman Suzi, Jun 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chris
    Replies:
    1
    Views:
    362
    John C. Bollinger
    Aug 19, 2003
  2. Jacek Dziedzic

    ifstream::get() surprise

    Jacek Dziedzic, Aug 26, 2004, in forum: C++
    Replies:
    5
    Views:
    4,191
    Jacek Dziedzic
    Aug 27, 2004
  3. John Hunter

    operator double() surprise in cxx

    John Hunter, Apr 30, 2004, in forum: Python
    Replies:
    7
    Views:
    408
    =?iso-8859-1?q?Beno=EEt_Dejean?=
    Apr 30, 2004
  4. Roman Suzi

    2.2 <-> 2.3 surprise

    Roman Suzi, May 31, 2004, in forum: Python
    Replies:
    0
    Views:
    351
    Roman Suzi
    May 31, 2004
  5. Shalabh Chaturvedi

    Re: 2.2 <-> 2.3 surprise

    Shalabh Chaturvedi, May 31, 2004, in forum: Python
    Replies:
    1
    Views:
    364
    Duncan Booth
    Jun 1, 2004
Loading...

Share This Page