A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-October/057411.html below:

[Python-Dev] Coroutines, generators, function calling

[Python-Dev] Coroutines, generators, function callingNick Coghlan ncoghlan at gmail.com
Tue Oct 18 16:17:22 CEST 2005
Andrew Koenig wrote:
>>   Sure, that would work.  Or even this, if the scheduler would
>> automatically recognize generator objects being yielded and so would run
>> the the nested coroutine until finish:
> 
> This idea has been discussed before.  I think the problem with recognizing
> generators as the subject of "yield" statements is that then you can't yield
> a generator even if you want to.
> 
> The best syntax I can think of without adding a new keyword looks like this:
> 
> 	yield from x
> 
> which would be equivalent to
> 
> 	for i in x:
> 	    yield i
> 
> Note that this equivalence would imply that x can be any iterable, not just
> a generator.  For example:
> 
> 	yield from ['Hello', 'world']
> 
> would be equivalent to
> 
> 	yield 'Hello'
> 	yield 'world'

Hmm, I actually quite like that. The best I came up with was "yield for", and 
that just didn't read correctly. Whereas "yield from seq" says exactly what it 
is doing.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4