Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-22 Thread Xavier Morel
On 22 Jan 2009, at 12:42 , Nick Coghlan wrote: Tino Wildenhain wrote: g=(i for i in xrange(1000))[2:5] g.next() # wrapper would now step 2 times w/o yield and 1 with yield 2 g.next() 3 g.next() 4 g.next() Traceback (most recent call last): File "", line 1, in StopIteration as expecte

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-22 Thread Tino Wildenhain
Nick Coghlan wrote: Tino Wildenhain wrote: g=(i for i in xrange(1000))[2:5] g.next() # wrapper would now step 2 times w/o yield and 1 with yield 2 g.next() 3 g.next() 4 g.next() Traceback (most recent call last): File "", line 1, in StopIteration as expected - this could be included i

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-22 Thread Nick Coghlan
Tino Wildenhain wrote: >>> g=(i for i in xrange(1000))[2:5] >>> g.next() # wrapper would now step 2 times w/o yield and 1 with yield > 2 >>> g.next() > 3 >>> g.next() > 4 >>> g.next() > Traceback (most recent call last): > File "", line 1, in > StopIteration > > as expected - this could be incl

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-22 Thread Tino Wildenhain
Hi, Gerald Britton wrote: The sieve is just one example. The basic idea is that for some infinite generator (even a very simple one) you want to cut it off after some point. As for the number of characters, I spelled lambda incorrectly (left out a b) and there should be a space after the colon

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-22 Thread Eric Smith
Terry Reedy wrote: Cameron Simpson wrote: Back at uni we had to implement a small language in our compilers class and the lecturer had specified a proper generic while loop, thus: loop: suite while invariant suite endloop In Python, that is spelled while True: suite if not

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Nick Coghlan
Terry Reedy wrote: > Steven D'Aprano wrote: >> Is that Xah Lee? It sounds like the sort of thing he'd say. > > It was the thread he started, but not him. He contributed other idiocies. Xah Lee is still around? I would have expected him to get bored and go away years ago... Cheers, Nick. -- Ni

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Nick Coghlan
Cameron Simpson wrote: > On 21Jan2009 14:02, Tres Seaver wrote: > | Vitor Bosshard wrote: > | > BTW, there is already an "until" keyword in python, it's called "while > not" ;) > | > | 'until' is used at least in some languages (Pascal, Modula*, maybe Ada?) > | for a "terminate at bottom" loop (

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Nick Coghlan
Gerald Britton wrote: > OK then, what is the feeling out there about extending the "for" > syntax in general (and by extension list comprehensions and generator > expressions) by adding an optional while clause like this: > > for in [while [ | not ]: > > > The predicate would be tested aft

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Terry Reedy
Cameron Simpson wrote: Back at uni we had to implement a small language in our compilers class and the lecturer had specified a proper generic while loop, thus: loop: suite while invariant suite endloop In Python, that is spelled while True: suite if not invariant: break

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Cameron Simpson
On 21Jan2009 14:02, Tres Seaver wrote: | Vitor Bosshard wrote: | > BTW, there is already an "until" keyword in python, it's called "while not" ;) | | 'until' is used at least in some languages (Pascal, Modula*, maybe Ada?) | for a "terminate at bottom" loop (one guaranteed to run at least once):

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Terry Reedy
Steven D'Aprano wrote: On Wed, 21 Jan 2009 03:10:24 pm Terry Reedy wrote: Steven D'Aprano wrote: The three clauses are neither in the same order, nor are they in reverse order. They are in the same order but rotated, with the last brought around to the front to emphasize it. Did you really

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Russell E. Owen
In article , rdmur...@bitdance.com wrote: >... > I understand that you are saying that 'while x' is used in the same > logical sense ("take a different action when x is no longer true"), > but that I don't feel that that is enough to say that it has similar > semantics. Or, perhaps more accurate

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Vitor Bosshard wrote: >> Some also allow for an "until" keyword. I'm not suggesting that we >> need to do this in Python; it's just interesting to note that there is >> some precedent for this approach. >> > > Well, you could propose changing the fo

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Aahz
On Wed, Jan 21, 2009, Gerald Britton wrote: > > OK then, what is the feeling out there about extending the "for" > syntax in general (and by extension list comprehensions and generator > expressions) by adding an optional while clause like this: > > for in [while [ | not ]: > What I sugges

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Ludvig Ericson
The following was supposed to go to the list: 18:29 Gerald Britton: Yes you could have long lines, but you wouldn't have to use it. You could still code it up as you would today. It might be convenient for shorter expressions though. 12:12 PM Ludvig Ericson: On Jan 21, 2009, at 16:51, Gera

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Gerald Britton
9 11:38:01 >> Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator >> expressions >> >> FWIW, there are a few historic languages that implement a compound >> for-loop: Algol 68, PL/I, SAS et al allow constructs that, if >> translat

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Vitor Bosshard
- Mensaje original > De: Gerald Britton > Para: rdmur...@bitdance.com > CC: python-dev@python.org > Enviado: miércoles, 21 de enero, 2009 11:38:01 > Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator > expressions > > FWIW, there

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Gerald Britton
FWIW, there are a few historic languages that implement a compound for-loop: Algol 68, PL/I, SAS et al allow constructs that, if translated to an equivalent (currently invalid) Python-style syntax would look like this" for in while : Some also allow for an "until" keyword. I'm not suggest

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread rdmurray
On Wed, 21 Jan 2009 at 21:46, Steven D'Aprano wrote: On Wed, 21 Jan 2009 03:10:24 pm Terry Reedy wrote: It is a carefully designed 1 to 1 transformation between multiple nested statements and a single expression. I'm sure that correspondence is obvious to some, but it wasn't obvious to me, and

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-21 Thread Steven D'Aprano
On Wed, 21 Jan 2009 03:10:24 pm Terry Reedy wrote: > Steven D'Aprano wrote: ... > > In a generator expression, we have: > > > > yielded-expr for-clause if-clause > > > > while the corresponding nested statements are: > > > > for-clause if-clause yielded-expr > > > > The three clauses are neither

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Terry Reedy
Steven D'Aprano wrote: Another argument against the PEP was that it breaks the correspondence between the generator expression and the equivalent for-loop. I had never even noticed such correspondence before, because to my eyes the most important term is the yielded expression, not the scaffo

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Terry Reedy
Gerald Britton wrote: I wonder if this is a bug? It is a known glitch reported last summer. Devs decided not to fix because doing so would, in the patches tried, slow list comps significantly. Also, the documented intent and expected usage of StopIteration is this "exception StopIteratio

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Steven D'Aprano
On Wed, 21 Jan 2009 03:56:06 am Antoine Pitrou wrote: > Alexey G. Shpagin udmvt.ru> writes: > > Example will look like > > g = (n for n in range(100) if n*n < 50 or else_break()) > > Please don't suggest any hack involving raising StopIteration as part > of a conditional statement in a generator

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Nick Coghlan
Gerald Britton wrote: > I wonder if this is a bug? Nope, it's part of the defined behaviour. Avoiding the overhead of the GE machinery is actually the main advantage in using a comprehension over the equivalent generator expression. Deliberately raising StopIteration is about the only way to notic

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Nick Coghlan
Antoine Pitrou wrote: > Alexey G. Shpagin udmvt.ru> writes: >> Example will look like >> g = (n for n in range(100) if n*n < 50 or else_break()) > > Please don't suggest any hack involving raising StopIteration as part of a > conditional statement in a generator expression. It might work today,

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread rdmurray
On Tue, 20 Jan 2009 at 16:56, Antoine Pitrou wrote: Alexey G. Shpagin udmvt.ru> writes: Example will look like g = (n for n in range(100) if n*n < 50 or else_break()) Please don't suggest any hack involving raising StopIteration as part of a conditional statement in a generator expression.

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Calvin Spealman
n-dev@python.org >>> Enviado: martes, 20 de enero, 2009 11:18:24 >>> Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator >>> expressions >>> >>> May I suggest you this variant? >>> >>> def raiseStopIteration():

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Gerald Britton
I wonder if this is a bug? On Tue, Jan 20, 2009 at 11:32 AM, Vitor Bosshard wrote: > - Mensaje original >> De: "python-3...@udmvt.ru" >> Para: Gerald Britton >> CC: python-dev@python.org >> Enviado: martes, 20 de enero, 2009 11:18:24 >> Asun

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Calvin Spealman
On Tue, Jan 20, 2009 at 12:00 PM, Vitor Bosshard wrote: > > > - Mensaje original >> De: Gerald Britton >> Para: Vitor Bosshard >> CC: python-3...@udmvt.ru; python-dev@python.org >> Enviado: martes, 20 de enero, 2009 13:40:07 >> Asunto: Re: [Python

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Vitor Bosshard
- Mensaje original > De: Gerald Britton > Para: Vitor Bosshard > CC: python-3...@udmvt.ru; python-dev@python.org > Enviado: martes, 20 de enero, 2009 13:40:07 > Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator > expressions > >

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Antoine Pitrou
Alexey G. Shpagin udmvt.ru> writes: > > Example will look like > g = (n for n in range(100) if n*n < 50 or else_break()) Please don't suggest any hack involving raising StopIteration as part of a conditional statement in a generator expression. It might work today, but it might as well break to

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Gerald Britton
2009 11:18:24 >> Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator >> expressions >> >> May I suggest you this variant? >> >> def raiseStopIteration(): >> raise StopIteration >> >> g = (n for n in

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Vitor Bosshard
- Mensaje original > De: "python-3...@udmvt.ru" > Para: Gerald Britton > CC: python-dev@python.org > Enviado: martes, 20 de enero, 2009 11:18:24 > Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator > expressions > >

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Sturla Molden
On 1/20/2009 4:45 PM, Gerald Britton wrote: OK, so your suggestion: g = (n for n in range(100) if n*n < 50 or raiseStopIteration()) really means "return in in the range 0-99 if n-squared is less than 50 or the function raiseStopIteration() returns True". How would this get the generator to st

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Gerald Britton
Yup, I tried your idea and it does work as I intended. It looks a little better than using takewhile, but not (to me anyway) as nice as my original suggestion. Still, if my idea is ultimately rejected (looks that way at the moment), this is a good alternative. On Tue, Jan 20, 2009 at 10:57 AM, A

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Alexey G. Shpagin
On Tue, Jan 20, 2009 at 10:45:27AM -0500, Gerald Britton wrote: > OK, so your suggestion: > > g = (n for n in range(100) if n*n < 50 or raiseStopIteration()) > > really means "return in in the range 0-99 if n-squared is less than 50 > or the function raiseStopIteration() returns True". > > How

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Gerald Britton
OK, so your suggestion: g = (n for n in range(100) if n*n < 50 or raiseStopIteration()) really means "return in in the range 0-99 if n-squared is less than 50 or the function raiseStopIteration() returns True". How would this get the generator to stop once n*n >=50? It looks instead like the fi

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Alexey G. Shpagin
On Tue, Jan 20, 2009 at 09:24:32AM -0500, Gerald Britton wrote: > hmmm...doesn't: > > if n*n < 50 or raise StopIteration() > > really mean, "Return an integer in the range 0-99 if n-squared is less > than fifty or the statement 'raise StopIteration()' returns True" ? > > I'm not sure that th

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread python-3000
On Mon, Jan 19, 2009 at 10:10:00AM -0500, Gerald Britton wrote: > Please find below PEP 3142: Add a "while" clause to generator > expressions. I'm looking for feedback and discussion. > ... > g = (n for n in range(100) while n*n < 50) May I suggest you this variant? def raiseStopI

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Gerald Britton
hmmm...doesn't: if n*n < 50 or raise StopIteration() really mean, "Return an integer in the range 0-99 if n-squared is less than fifty or the statement 'raise StopIteration()' returns True" ? I'm not sure that that will work. On Tue, Jan 20, 2009 at 9:18 AM, wrote: > On Mon, Jan 19, 2009

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-20 Thread Nick Coghlan
Kristján Valur Jónsson wrote: > Are you all certain that this mapping from a generator expression to > a foor loop isn't just a happy coincidence? After all, the generator > statement is just a generalization of the list comprehension and that > doesn't map quite so directly. The mapping of the fo

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Cameron Simpson
On 19Jan2009 19:42, Calvin Spealman wrote: | OK, I still don't like the general idea, but I have a suggestion for | what I think is a more favorable syntax, anyway. Basically, adding the | allowance of an 'else break' when there is an if clause in a generator | expression or list comprehension. I

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Calvin Spealman
OK, I still don't like the general idea, but I have a suggestion for what I think is a more favorable syntax, anyway. Basically, adding the allowance of an 'else break' when there is an if clause in a generator expression or list comprehension. I still dont think it should be done, but it is a more

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Terry Reedy
Kristján Valur Jónsson wrote: Are you all certain that this mapping from a generator expression to a foor loop isn't just a happy coincidence? Yes, The manual *defines* the meaning of a comprehension in terms of the corresponding nested statements. "The comprehension consists of a single exp

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Kristján Valur Jónsson
Sent: 19. janúar 2009 17:52 To: python-dev@python.org Subject: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions The other, posted by Steven Bethard, is that it fundamentally breaks the current semantics of abbreviating (except for iteration variable scoping) an '

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Nick Coghlan
Steven Bethard wrote: > -1. As I pointed out on python-ideas, this proposal makes "while" mean > something different in a generator expression. While I initially found the suggestion in the PEP rather cute, that isn't enough to make it a good idea as a language addition. So, -1 for a few reasons:

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Sturla Molden
On 1/19/2009 6:51 PM, Terry Reedy wrote: The other, posted by Steven Bethard, is that it fundamentally breaks the current semantics of abbreviating (except for iteration variable scoping) an 'equivalent' for loop. The proposed syntax would suggest that this should be legal as well: for i in

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Brett Cannon
On Mon, Jan 19, 2009 at 10:03, Gerald Britton wrote: > Duly noted and thanks for the feedback! (just what I was looking for > actually). I do disagree with the idea that the proposal, if > implemented, would make Python harder to learn. Not sure who would > find it harder. Having to find and u

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Paul Moore
2009/1/19 Vitor Bosshard : > Are you even sure the list comprehension doesn't already shortcut evaluation? > > This quick test in 2.6 hints otherwise: > > a = (i for i in range(10) if i**2<10) Yes, but your test, once it becomes true, remains so. Consider >>> list(n for n in range(10) if n%2

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Alexander Belopolsky
On Mon, Jan 19, 2009 at 1:41 PM, Scott Dial wrote: > Vitor Bosshard wrote: >> Are you even sure the list comprehension doesn't already shortcut evaluation? > > It does not. The body of the comprehension is evaluated all the way to > completion, .. In addition, the test is evaluated on all items a

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gustavo Carneiro
2009/1/19 Vitor Bosshard > > > > > - Mensaje original > > De: Gerald Britton > > Para: Terry Reedy > > CC: python-dev@python.org > > Enviado: lunes, 19 de enero, 2009 15:03:47 > > Asunto: Re: [Python-Dev] PEP 3142: Add a "while" c

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Scott Dial
Vitor Bosshard wrote: > Are you even sure the list comprehension doesn't already shortcut evaluation? It does not. The body of the comprehension is evaluated all the way to completion, despite the fact that a.next() does not return until there is a successful test of the if expression. >>> def pr

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Vitor Bosshard
- Mensaje original > De: Gerald Britton > Para: Terry Reedy > CC: python-dev@python.org > Enviado: lunes, 19 de enero, 2009 15:03:47 > Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator > expressions > > Duly noted and thanks f

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gerald Britton
Duly noted and thanks for the feedback! (just what I was looking for actually). I do disagree with the idea that the proposal, if implemented, would make Python harder to learn. Not sure who would find it harder. Having to find and use takewhile was harder for me. I still find that one counter-

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Terry Reedy
Gerald Britton wrote: Please find below PEP 3142: Add a "while" clause to generator expressions. I'm looking for feedback and discussion. This was already discussed on python-ideas where it got negative feedback. One objection, mentioned by Mathias Panzerbock and Georg Brandl, is that it is

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Steven Bethard
On Mon, Jan 19, 2009 at 7:10 AM, Gerald Britton wrote: > PEP: 3142 > Title: Add a "while" clause to generator expressions [snip] > numbers in that range. Allowing for a "while" clause would allow > the redundant tests to be short-circuited: > > g = (n for n in range(100) while n*n < 50) >

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Calvin Spealman
On Mon, Jan 19, 2009 at 11:41 AM, Gerald Britton wrote: > Thanks Calvin, > > Could you please expand on your thoughts about possible confusion? > That is, how do you see a programmer becoming confused if this option > were added to the syntax. I think that the difference between these two lines i

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gerald Britton
The sieve is just one example. The basic idea is that for some infinite generator (even a very simple one) you want to cut it off after some point. As for the number of characters, I spelled lambda incorrectly (left out a b) and there should be a space after the colon to conform to design guides.

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Daniel Stutzbach
On Mon, Jan 19, 2009 at 10:37 AM, Gerald Britton wrote: >prime = (p for p in sieve() while p < 1000) >prime = takewhile(lamda p:p<1000, sieve()) > I'm pretty sure the extra cost of evaluating the lambda at each step is tiny compared to the cost of the sieve, so I don't you can make a conv

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Facundo Batista
2009/1/19 Gerald Britton : > Could you please expand on your thoughts about possible confusion? > That is, how do you see a programmer becoming confused if this option > were added to the syntax. My main concern about confusion is that you're adding a "while" that actually will behave like a "bre

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gerald Britton
Thanks Calvin, Could you please expand on your thoughts about possible confusion? That is, how do you see a programmer becoming confused if this option were added to the syntax. On Mon, Jan 19, 2009 at 11:29 AM, Calvin Spealman wrote: > I am really unconvinced of the utility of this proposal and

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gerald Britton
Sure: Say I implement the sieve of Eratosthenes as a prime number generator. I want some primes for my application but there are an infinite number of primes. So I would like to write: prime = (p for p in sieve() while p < 1000) instead of: import itertools prime = takewhile(lamda

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Calvin Spealman
I am really unconvinced of the utility of this proposal and quite convinced of the confusing factor it may well add to the current syntax. I would like to see more applicable examples. It would replace uses of takewhile, but that isn't a really often used function. So, is there any evidence to supp

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Daniel Stutzbach
On Mon, Jan 19, 2009 at 9:10 AM, Gerald Britton wrote: > g = (n for n in range(100) if n*n < 50) > > would yield 0, 1, 2, 3, 4, 5, 6 and 7, but would also consider > the numbers from 8 to 99 and reject them all since n*n >= 50 for > numbers in that range. Allowing for a "while" clause wou

Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Benjamin Peterson
On Mon, Jan 19, 2009 at 9:10 AM, Gerald Britton wrote: > Please find below PEP 3142: Add a "while" clause to generator > expressions. I'm looking for feedback and discussion. > > > PEP: 3142 > Title: Add a "while" clause to generator expressions > Version: $Revision: 68715 $ > Last-Modified: $Dat

[Python-Dev] PEP 3142: Add a "while" clause to generator expressions

2009-01-19 Thread Gerald Britton
Please find below PEP 3142: Add a "while" clause to generator expressions. I'm looking for feedback and discussion. PEP: 3142 Title: Add a "while" clause to generator expressions Version: $Revision: 68715 $ Last-Modified: $Date: 2009-01-18 11:28:20 +0100 (So, 18. Jan 2009) $ Author: Gerald Britt