[Python-3000] sets in P3K?

Josiah Carlson jcarlson at uci.edu
Wed Apr 26 20:34:42 CEST 2006


Edward Loper <edloper at gradient.cis.upenn.edu> wrote:
> 
> I think that a significant motivation for people that propose set 
> literals is that the following is just plain ugly:
> 
>     s = set([1,2,3])
> 
> It seems much more natural to write:
> 
>     s = set(1, 2, 3)

I agree.

> However, it is fairly common to want to build a set from a collection, 
> an iterator, or a genexp.  With the current notation, all three of these 
> are easy.  But with this "more natural" notation, they're no longer 
> possible without resorting to varargs (which would create an unnecessary 
> imtermediary tuple).

Right now you are manually creating an intermediate list or tuple to
pass to set, so this wouldn't seem to be a significant change to me
(it's just an argument semantic addition).

 - Josiah



More information about the Python-3000 mailing list