Re: Yielding a chain of values

2005-09-09 Thread [EMAIL PROTECTED]
I'm not really worry that much over O(n^2) performace (especially having optimized some O(n^3) SQL operations :-o !) The things is this really should be an O(n) operation. Having a yield all statement or expression is useful in its own right and also potentially a way to optimized away the O(n^2)

Re: Yielding a chain of values

2005-09-09 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>>unless you are going many levels deep > (and that's usually a design smell of some kind) > > No, its not a bug. its a feature! See the discussion in the recursive > generator thread below: http://groups.google.com/group/comp.lang.pyth

Re: Yielding a chain of values

2005-09-09 Thread [EMAIL PROTECTED]
>>unless you are going many levels deep (and that's usually a design smell of some kind) No, its not a bug. its a feature! See the discussion in the recursive generator thread below: http://groups.google.com/group/comp.lang.python/browse_frm/thread/4c749ec4fc5447fb/36f2b915eba66eac?q=recursive+ge

Re: Yielding a chain of values

2005-09-07 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > dude - this business is so confusing that you actually have to *think* > about it! > but python is all about simplicity. > with python, when I program - I don't think *about* it - I think it. or > something - don't make me think about it. > > so how about a "reyield" or

Re: Yielding a chain of values

2005-09-07 Thread yairchu
dude - this business is so confusing that you actually have to *think* about it! but python is all about simplicity. with python, when I program - I don't think *about* it - I think it. or something - don't make me think about it. so how about a "reyield" or some other new keyword (cause reyield i

Re: Yielding a chain of values

2005-09-01 Thread viridia
This is why my original proposal used the '*' operator rather than a keyword. The reasoning behind this is as follows: When calling a function, a parameter of the form "*expression" expands to a list of arguments. From the Python reference manual: "If the syntax '*expression' appears in the functi

Re: Yielding a chain of values

2005-08-31 Thread Kay Schluehr
Reinhold Birkenfeld wrote: > Kay Schluehr wrote: > > Reinhold Birkenfeld wrote: > > > >> > x = [ yield r for r in iterable ] > >> > >> Which is quite different from > >> > >> x = (yield) in iterable > >> > >> which is currently (PEP 342) equivalent to > >> > >> _ = (yield) > >> x = _ in iterable >

Re: Yielding a chain of values

2005-08-31 Thread Reinhold Birkenfeld
Kay Schluehr wrote: > Reinhold Birkenfeld wrote: > >> >x = [ yield r for r in iterable ] >> >> Which is quite different from >> >> x = (yield) in iterable >> >> which is currently (PEP 342) equivalent to >> >> _ = (yield) >> x = _ in iterable >> >> So, no further tinkering with yield, I'm afra

Re: Yielding a chain of values

2005-08-31 Thread Kay Schluehr
Reinhold Birkenfeld wrote: > > x = [ yield r for r in iterable ] > > Which is quite different from > > x = (yield) in iterable > > which is currently (PEP 342) equivalent to > > _ = (yield) > x = _ in iterable > > So, no further tinkering with yield, I'm afraid. > > Reinhold Is the statement

Re: Yielding a chain of values

2005-08-31 Thread Reinhold Birkenfeld
Matt Hammond wrote: >> Well, maybe it's right both ways ;-) I.e., even though yield "is" now >> an expression, it is valid to use it as an expression-statement which >> evaluates the expression and discards the value. So I think you could >> still use the currently illegal "yield in" token sequence

Re: Yielding a chain of values

2005-08-31 Thread Matt Hammond
> Well, maybe it's right both ways ;-) I.e., even though yield "is" now > an expression, it is valid to use it as an expression-statement which > evaluates the expression and discards the value. So I think you could > still use the currently illegal "yield in" token sequence to mean that > what fol

Re: Yielding a chain of values

2005-08-31 Thread Bengt Richter
On Tue, 30 Aug 2005 21:23:39 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> On Tue, 30 Aug 2005 23:12:35 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> >> wrote: >>>Bengt Richter wrote: Maybe yield in inner() could be sugar for the above and beco

Re: Yielding a chain of values

2005-08-30 Thread Peter Hansen
Bengt Richter wrote: > On Tue, 30 Aug 2005 23:12:35 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> > wrote: >>Bengt Richter wrote: >>>Maybe >>> yield in inner() >>> >>>could be sugar for the above and become something optimized? >> >>The problem here is that yield isn't a statement any mor

Re: Yielding a chain of values

2005-08-30 Thread Bengt Richter
On Tue, 30 Aug 2005 23:12:35 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> On Tue, 30 Aug 2005 12:18:59 GMT, Michael Hudson <[EMAIL PROTECTED]> wrote: >> >>>Talin <[EMAIL PROTECTED]> writes: >>> I'm finding that a lot of places within my code, I want to retu

Re: Yielding a chain of values

2005-08-30 Thread Reinhold Birkenfeld
Bengt Richter wrote: > On Tue, 30 Aug 2005 12:18:59 GMT, Michael Hudson <[EMAIL PROTECTED]> wrote: > >>Talin <[EMAIL PROTECTED]> writes: >> >>> I'm finding that a lot of places within my code, I want to return the >>> output of a generator from another generator. Currently the only >>> method I kn

Re: Yielding a chain of values

2005-08-30 Thread Bengt Richter
On Tue, 30 Aug 2005 12:18:59 GMT, Michael Hudson <[EMAIL PROTECTED]> wrote: >Talin <[EMAIL PROTECTED]> writes: > >> I'm finding that a lot of places within my code, I want to return the >> output of a generator from another generator. Currently the only >> method I know of to do this is to explici

Re: Yielding a chain of values

2005-08-30 Thread Michael Hudson
Talin <[EMAIL PROTECTED]> writes: > I'm finding that a lot of places within my code, I want to return the > output of a generator from another generator. Currently the only > method I know of to do this is to explicitly loop over the results > from the inner generator, and yield each one: > >

Re: Yielding a chain of values

2005-08-28 Thread Peter Hansen
Talin wrote: > I'm finding that a lot of places within my code, I want to return the > output of a generator from another generator. Currently the only method > I know of to do this is to explicitly loop over the results from the > inner generator, and yield each one: > >for x in inner(

Yielding a chain of values

2005-08-28 Thread Talin
I'm finding that a lot of places within my code, I want to return the output of a generator from another generator. Currently the only method I know of to do this is to explicitly loop over the results from the inner generator, and yield each one: for x in inner(): yield x