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