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

[Python-Dev] zip() andlist-comprehension with commas)

permuting several lists (was Re: [Python-Dev] zip() andlist-comprehension with commas)Paul Prescod paul@prescod.net
Thu, 13 Jul 2000 01:12:57 -0500
Ken Manheimer wrote:
> 
> ...
>
> Seem like there are so many contexts
> where lists and tuples are interchangeable that it's too easy for a
> variable to contain one when you expect the other - and the
> reorganizing routine would wind up raising unexpected errors, or
> unpredictable results, too often.  

Well, we (at least you and I) agree that we should use a generator, so
you don't really have any control over the outer data structure without
using a cast. I think it is safe to default the inner data structure to
tuple. Tuples are safe because errors involving them cause TypeErrors
whereas accidental writes to shared lists cause weird mutation bugs.

Here are some variants you can get using recently proposed features:

List of tuples:

>>> list( lace( a, b, c ))

A tuple of tuples:

>>> tuple( lace( a, b, c))

A tuple of lists:

>>> tuple( [for x in lace( a, b, c)]: list(x) )

A list of lists:

>>> list( [for x in lace( a, b, c)]: list(x) )

A dictionary:

>>> dict( lace( a, b, c ))

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