RE: For review: PEP 343: Anonymous Block Redux andGeneratorEnhancements

Discussion in 'Python' started by Delaney, Timothy C (Timothy), Jun 6, 2005.

  1. Nicolas Fleury wrote:

    > def getFirstLine(filename):
    > with opening(filename) as file
    > return file.readline()


    Your tastes definitely disagree with the majority of Python programmers
    then, including Guido. Scoping is defined in Python by indentation.

    If you want the above sort of thing, you're going to have to write a new
    PEP, and I'd be very surprised to see it accepted. But there's nothing
    stopping you from doing so.

    > def getFirstLine(filename):
    > with opening(filename) as file:
    > return file.readline()


    This is beautiful and explicit. What else could you want?

    The syntax:

    with EXPR1 as VAR1, EXPR2 as VAR2:
    ...

    was discussed on python-dev. It wasn't explicitly rejected, but the
    feeling seemed to be that it was an unnecessary complication as far as
    PEP 343 is concerned. There's nothing stopping another PEP proposing
    this as an extension to PEP 343, and there's nothing stopping that being
    in Python 2.5 if it's accepted.

    PEP 343 was originally PEP 340 (and several other things) and was quite
    complicated at one point (it originally contained PEP 342 as well). The
    PEP in its current state represents 2 months of discussion, complication
    and (finally) simplification. Its semantics are clear and unambiguous.
    And (as Guido states) it will obsolete 4(?) other PEPs.

    Be sure to read the referenced PEPs (and the ones referenced from them)
    - they contain a lot of history. Also read PEP 346 for a competing PEP
    to PEPs 340 and 343 that gradually converged to PEP 343 - most
    importantly, it contains the rejected options (that seem to have been
    lost from PEPs 340 and 343).

    Tim Delaney
    Delaney, Timothy C (Timothy), Jun 6, 2005
    #1
    1. Advertising

  2. Delaney, Timothy C (Timothy)

    Paul Rubin Guest

    Re: For review: PEP 343: Anonymous Block Redux and GeneratorEnhancements

    "Delaney, Timothy C (Timothy)" <> writes:
    > Be sure to read the referenced PEPs (and the ones referenced from them)
    > - they contain a lot of history. Also read PEP 346 for a competing PEP
    > to PEPs 340 and 343 that gradually converged to PEP 343 - most
    > importantly, it contains the rejected options (that seem to have been
    > lost from PEPs 340 and 343).


    There was an interesting proposal (later rejected) from Raymond
    Hettinger a while back, that allowed passing arguments into a
    suspended generator, where they could be seen by the yield statement.
    I don't remember specifics and it doesn't seem to be in any of those PEP's.

    Anyone remember more? I wonder whether 343 could somehow resurrect
    the good parts of that.
    Paul Rubin, Jun 6, 2005
    #2
    1. Advertising

  3. Delaney, Timothy C (Timothy)

    Mike Meyer Guest

    Paul Rubin <http://> writes:

    > "Delaney, Timothy C (Timothy)" <> writes:
    >> Be sure to read the referenced PEPs (and the ones referenced from them)
    >> - they contain a lot of history. Also read PEP 346 for a competing PEP
    >> to PEPs 340 and 343 that gradually converged to PEP 343 - most
    >> importantly, it contains the rejected options (that seem to have been
    >> lost from PEPs 340 and 343).

    >
    > There was an interesting proposal (later rejected) from Raymond
    > Hettinger a while back, that allowed passing arguments into a
    > suspended generator, where they could be seen by the yield statement.
    > I don't remember specifics and it doesn't seem to be in any of those PEP's.
    >
    > Anyone remember more? I wonder whether 343 could somehow resurrect
    > the good parts of that.


    It sounds like you're remembering PEP 342. 343 references that, but
    doesn't include much of it.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Jun 6, 2005
    #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. Guido van Rossum
    Replies:
    21
    Views:
    609
    Steven Bethard
    Jun 6, 2005
  2. Ron Adam

    PEP 343, second look

    Ron Adam, Jun 22, 2005, in forum: Python
    Replies:
    2
    Views:
    311
    Ron Adam
    Jun 22, 2005
  3. falcon
    Replies:
    0
    Views:
    307
    falcon
    Aug 4, 2005
  4. falcon
    Replies:
    0
    Views:
    266
    falcon
    Aug 5, 2005
  5. Rk Ch
    Replies:
    3
    Views:
    104
    Damjan Rems
    Apr 30, 2008
Loading...

Share This Page