Paul == Paul Moore [EMAIL PROTECTED] writes:
Paul You can work around the need for something like yield_all,
Paul or explicit loops, by defining an iflatten generator,
Paul which yields every element of its (iterable) argument,
Paul unless the element is a generator, in which
Douglas Alan wrote:
Wouldn't
yield *(x for x in gen1(arg))
be sufficient, and would already be supported by the proposal at
hand?
It would, but, as Steven pointed out, the * in func(*args) results in
tuple(args) being passed to the underlying function.
So I see no reason to expect yield
Jeremy Bowers wrote:
At first I liked this, but the reason that is a syntax error is that it is
supposed to be
def f():
yield (x for x in gen1(arg))
which today on 2.4 returns a generator instance which will in turn
yield one generator instance from the genexp
And it would continue to do so in
Skip Montanaro [EMAIL PROTECTED] writes:
Dougdef foogen(arg1):
Doug def foogen1(arg2):
Doug # Some code here
Doug # Some code here
Doug yield_all foogen1(arg3)
Doug # Some code here
Doug yield_all foogen1(arg4)
On Thu, 03 Mar 2005 20:47:42 +, Paul Moore wrote:
This can probably be tidied up and improved, but it may be a
reasonable workaround for something like the original example.
This is why even though in some sense I'd love to see yield *expr, I can't
imagine it's going to get into the
Douglas Alan wrote:
Steve Holden [EMAIL PROTECTED] writes:
Guido has generally observed a parsimony about the introduction of
features such as the one you suggest into Python, and in particular
he is reluctant to add new keywords - even in cases like decorators
that cried out for a keyword rather
Douglas Alan wrote:
Steven Bethard [EMAIL PROTECTED] writes:
I'm guessing the * syntax is pretty unlikely to win Guido's
approval. There have been a number of requests[1][2][3] for syntax
like:
x, y, *rest = iterable
Oh, it is so wrong that Guido objects to the above. Python needs
fully
Steven Bethard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Douglas Alan wrote:
In this case, that is great, since I'd much prefer
yield *gen1(arg)
than
yield_all gen1(arg)
I'm guessing the * syntax is pretty unlikely to win Guido's approval.
There have been a
Terry Reedy wrote:
Steven Bethard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
My suspicion is that if he doesn't like the * syntax when there's a close
parallel to the argument parsing usage, he's not likely to like it when
there isn't one.
Hmm. My impression is that Guido did
Nick Coghlan [EMAIL PROTECTED] writes:
If you do write a PEP, try to get genexp syntax supported by the
yield keyword.
That is, the following currently triggers a syntax error:
def f():
yield x for x in gen1(arg)
Wouldn't
yield *(x for x in gen1(arg))
be sufficient, and would
On Wed, 02 Mar 2005 22:54:14 +1000, Nick Coghlan wrote:
Douglas Alan wrote:
Steve Holden [EMAIL PROTECTED] writes:
Guido has generally observed a parsimony about the introduction of
features such as the one you suggest into Python, and in particular
he is reluctant to add new keywords - even in
Jeremy At first I liked this, but the reason that is a syntax error is
Jeremy that it is supposed to be
Jeremy def f():
Jeremy yield (x for x in gen1(arg))
Jeremy which today on 2.4 returns a generator instance which will in
Jeremy turn yield one generator instance
Le mercredi 2 Mars 2005 21:32, Skip Montanaro a écrit :
def f():
yield from (x for x in gen1(arg))
Skip
This suggestion had been made in a previous posting and it has my preference :
def f():
yield from gen1(arg)
Regards
Francis
--
Terry Reedy wrote:
Douglas Alan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
We can shorten the code--and make it run in O(N) time--by adding a
new
keyword to replace the for v in ...: yield v pattern:
Maybe. Until you define the semantics of yield_all and at least outline
Op 2005-03-01, Steve Holden schreef [EMAIL PROTECTED]:
Terry Reedy wrote:
Douglas Alan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
We can shorten the code--and make it run in O(N) time--by adding a
new
keyword to replace the for v in ...: yield v pattern:
Maybe.
Andrew Dalke [EMAIL PROTECTED] writes:
On Mon, 28 Feb 2005 18:25:51 -0500, Douglas Alan wrote:
While writing a generator, I was just thinking how Python needs a
yield_all statement. With the help of Google, I found a
pre-existing discussion on this from a while back in the
Lightweight
Terry Reedy [EMAIL PROTECTED] writes:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code more readable and maintainable,
which is the one of the primary reasons that I use Python.
Douglas Alan wrote:
Terry Reedy [EMAIL PROTECTED] writes:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code more readable and maintainable,
which is the one of the primary
Duncan Booth [EMAIL PROTECTED] writes:
Douglas Alan wrote:
Terry Reedy [EMAIL PROTECTED] writes:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code more readable and
On Tue, 01 Mar 2005 12:42:51 -0600, Skip Montanaro wrote:
yield expr
yield *expr
(Mu-hu-ha-ha-ha!)
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
You absolutely and definitively have my vote.
When I first learned the generators , I was even wondering if there was
something wrong in what I do when faced with the sub-generators problem you
describe. I was wondering why am I doing this extra for-loop ? Is there
something wrong ? Can
Skip Montanaro wrote:
...
If this idea advances I'd rather see extra syntactic sugar introduced to
complement the current yield statement instead of adding a new keyword.
It's a bit clumsy to come up with something that will work syntactically
since the next token following the yield keyword can
Mike C. Fletcher wrote:
... it nicely encapsulates the learning of generators so that
when you see yield up front you know something generatish is going on.
+1 for generatish as VOTW (Vocabulation of the Week). =)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
In article [EMAIL PROTECTED],
Douglas Alan [EMAIL PROTECTED] wrote:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code more readable and maintainable,
which is the one of the
Douglas Alan [EMAIL PROTECTED] wrote:
While writing a generator, I was just thinking how Python needs a
yield_all statement. With the help of Google, I found a
pre-existing discussion on this from a while back in the Lightweight
Languages mailing list. I'll repost it here in order to improve
Hi,
No, this won't do. What is needed is a way to yield the results of a generator
from inside another generator with having to do a for-yield-loop inside the
outter generator.
Regards,
Francis Girard
Le mardi 1 Mars 2005 22:35, Adam Przybyla a crit:
... mayby that way:
ython 2.2.3 (#1,
Oops. I meant without having instead of with having which is a syntax
error.
Regards
Le mardi 1 Mars 2005 22:53, Francis Girard a crit:
No, this won't do. What is needed is a way to yield the results of a
generator from inside another generator with having to do a for-yield-loop
inside the
Francis Girard [EMAIL PROTECTED] writes:
Therefore, the suggestion you make, or something similar, would have
actually ease my learning, at least for me.
Yes, I agree 100%. Not having something like yield_all hurt my
ability to learn to use Python's generators quickly because I figured
that
David Eppstein [EMAIL PROTECTED] writes:
In article [EMAIL PROTECTED],
Douglas Alan [EMAIL PROTECTED] wrote:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code more readable
Douglas Alan wrote:
David Eppstein [EMAIL PROTECTED] writes:
In article [EMAIL PROTECTED],
Douglas Alan [EMAIL PROTECTED] wrote:
Cetainly, if yield_all
iterator == for i in iterator: yield i, I don't see how anything
is gained except for a few keystrokes.
What's gained is making one's code
Steve Holden [EMAIL PROTECTED] writes:
Guido has generally observed a parsimony about the introduction of
features such as the one you suggest into Python, and in particular
he is reluctant to add new keywords - even in cases like decorators
that cried out for a keyword rather than the ugly @
Douglas Alan wrote:
In this case, that is great, since I'd much prefer
yield *gen1(arg)
than
yield_all gen1(arg)
I'm guessing the * syntax is pretty unlikely to win Guido's approval.
There have been a number of requests[1][2][3] for syntax like:
x, y, *rest = iterable
for unpacking a
Steven Bethard [EMAIL PROTECTED] writes:
I'm guessing the * syntax is pretty unlikely to win Guido's
approval. There have been a number of requests[1][2][3] for syntax
like:
x, y, *rest = iterable
Oh, it is so wrong that Guido objects to the above. Python needs
fully destructuring
Douglas == Douglas Alan [EMAIL PROTECTED] writes:
Douglas If you'll reread what I wrote, you'll see that I'm not
Douglas concerned with performance, but rather my concern is that
Douglas I want the syntactic sugar. I'm tired of writing code
Douglas that looks like
Douglas
Isaac == Isaac To [EMAIL PROTECTED] writes:
def gen_all(gen):
for e in gen:
yield e
def foogen(arg1):
def foogen1(arg2):
# Some code here
# Some code here
gen_all(arg3)
^ I mean foogen1(arg3), obviously, and similar for below
# Some code here
Isaac To [EMAIL PROTECTED] writes:
Isaac == Isaac To [EMAIL PROTECTED] writes:
def gen_all(gen):
for e in gen:
yield e
def foogen(arg1):
def foogen1(arg2):
# Some code here
# Some code here
gen_all(arg3)
^ I mean foogen1(arg3), obviously,
Douglas == Douglas Alan [EMAIL PROTECTED] writes:
Douglas If you actually try doing this, you will see why I want
Douglas yield_all.
Oh... I see your point.
I was about to suggest that the code in my posts before should be made
to work somehow. I mean, if in
def fun1(x):
if
While writing a generator, I was just thinking how Python needs a
yield_all statement. With the help of Google, I found a
pre-existing discussion on this from a while back in the Lightweight
Languages mailing list. I'll repost it here in order to improve the
chances of this enhancement actually
On Mon, 28 Feb 2005 18:25:51 -0500, Douglas Alan wrote:
While writing a generator, I was just thinking how Python needs a
yield_all statement. With the help of Google, I found a pre-existing
discussion on this from a while back in the Lightweight Languages
mailing list. I'll repost it here
39 matches
Mail list logo