[Python-3000] sets in P3K?

Raymond Hettinger rhettinger at ewtllc.com
Tue Apr 25 17:34:05 CEST 2006


Greg Wilson wrote:

>One of the reasons I'd like native syntax for sets is that I'd like set
>comprehensions:
>
>    a = {b for b in c where b > 0}
>
>
>  
>

This is no good.  That form could as easily represent a frozenset 
comprehension or dict comprehension. It buys us nothing over the clear 
and unambiguous form we have now:

   set(b for b in collection if b > 0)

Distinguishing between sets, frozensets, and dicts is an insurmountable 
hurdle for punctuation based proposals (because you can't make the 
distinctions without introducing complexity).  Besides, there are no 
real gains to be had -- adding punctuation seems to have become a quest 
unto itself.

Embrace genexps -- they are a path to uniform and clear expression 
across a wide range of datatypes.

Avoid punctuation and funky syntax -- they burden the learning curve, 
they do not generalize well, they challenge parsers (both human and 
electronic), and they throw-away the clarity affored by spelled-out 
datatype names.



Raymond







More information about the Python-3000 mailing list