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/2000-July/006118.html below:

[Python-Dev] list comprehensions again...

[Python-Dev] list comprehensions again...Paul Prescod paul@prescod.net
Tue, 11 Jul 2000 15:44:06 -0500
I'm sorry to muddy the waters, but perhaps a solution is to try and stay
as close to regular Python syntax as possible. I am thinking of a nested
comprehension as a regular nested for-loop that has an expression rather
than a suite as its body:

Nested (List):

[for x in (0,10,20,30):
	for y in (0,1,2,3):
		x+y]
[0,11,22,33]


Parallel (Tuple):

(for x in (0,10,20,30) and y in (0,1,2,3):
	x+y)
(0,11,22,33)


Parallel (Dict):

{for x in (0,10,20,30) and y in range (0,1,2,3):
	x,y}

The dict one needs a little explaining. A dict comprehension is a
comprehension where the delimiters are curly braces and the generated
items are required to be pairs.

-- 
 Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html



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