Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: For review: PEP 343: Anonymous Block Redux andGeneratorEnhancements

Reply
Thread Tools

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

 
 
Delaney, Timothy C (Timothy)
Guest
Posts: n/a
 
      06-06-2005
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
 
Reply With Quote
 
 
 
 
Paul Rubin
Guest
Posts: n/a
 
      06-06-2005
"Delaney, Timothy C (Timothy)" <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      06-06-2005
Paul Rubin <http://(E-Mail Removed)> writes:

> "Delaney, Timothy C (Timothy)" <(E-Mail Removed)> 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 <(E-Mail Removed)> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
About Rational Number (PEP 239/PEP 240) Lie Python 25 12-18-2007 06:13 AM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
For review: PEP 343: Anonymous Block Redux and Generator Enhancements Guido van Rossum Python 21 06-05-2005 11:30 PM
PEP for new modules (I read PEP 2) Christoph Becker-Freyseng Python 3 01-16-2004 04:26 PM



Advertisments