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/057462.html below:

[Python-Dev] Coroutines, generators, function calling

[Python-Dev] Coroutines, generators, function callingAndrew Koenig ark at acm.org
Thu Oct 20 01:17:05 CEST 2005
> We yield values from inside for loops all over the place, but the
> yielded value is very rarely just the index value (only 1 of 14 yields)
> , but something calculated from the index value, so the new syntax would
> not be useful, unless it was something that provided access to the index
> item as a variable, like:
> 
> yield foo(i) for i in x
> 
> which barely saves you anything (a colon, a newline, and an indent).
> (hey wait, isn't that a generator comprehension? 

Here's a use case:

	def preorder(tree):
		if tree:
			yield tree
			yield from preorder(tree.left)
			yield from preorder(tree.right)



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