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

[Python-Dev] zip() and list-comprehension with commas

[Python-Dev] zip() and list-comprehension with commasPaul Prescod paul@prescod.net
Wed, 12 Jul 2000 04:44:07 -0500
Ka-Ping Yee wrote:
> 

> 
> As for the SyntaxError, i think it's a good idea because the
> example could be ambiguous.  You would have to either say
> 
>     [(x, y), for x in list1, if x > 1, for y in list2, if y > 2]
> 
> or
> 
>     [x] + [y, for x in list1, if x > 1, for y in list2, if y > 2]


The easy way to avoid the ambiguity is to dump the comma and use colons
as Guido intended.

[for x in list1:
	 if x > 1:
		 for y in list2:
			 if y > 2:
				(x,y)]

-- 
 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