Tuple comprehension

Jeff Shannon jeff at ccvcorp.com
Fri Apr 12 13:36:40 EDT 2002


In article <slrnabchd7.c8l.mlh at vier.idi.ntnu.no>, 
mlh at vier.idi.ntnu.no says...

> [...]  It just seems natural to do
> 
>   geometry = (state[name] for name in names)
> 
> (I'm assuming that the added parentheses would signal the tuple
> comprehension, just like the added brackets will signal generator
> comprehension.)

This wouldn't work -- the parser already recognizes parentheses 
as expression grouping.  Even if we *could* make the parser smart 
enough to recognize a tuple-comp, it would be confusing to read, 
at least IMO.

I also agree with Dave Brueck, that the cases in which tuples 
hold uniform values (so that tuple comprehensions might make 
sense) are relatively rare, compared to cases in which tuples 
hold heterogeneous values.  (This is exactly the opposite case of 
lists, which may be heterogeneous but are usually homogenous.)  
So ISTM that tuple comprehensions would be of limited utility.

-- 

Jeff Shannon
Technician/Programmer
Credit International



More information about the Python-list mailing list