[Python-3000] sets in P3K?

Greg Wilson gvwilson at cs.utoronto.ca
Wed May 3 15:22:40 CEST 2006


> From: Raymond Hettinger <rhettinger at ewtllc.com>
> Set literals are not worth committing atrocities elsewhere in the
> language.

I think "atrocities" is a little strong...

> I think Guido had the best solution.  Use set() for empty sets, use {}
> for empty dicts, use {genexp} for set comprehensions/displays, use
> {1,2,3} for explicit set literals, and use {k1:v1, k2:v2} for dict
> literals.  We can always add {/} later if demand exceeds distaste.

I obviously haven't done the experiment yet, but I can pretty much
guarantee you that newbies will trip over the inconsistency you're
proposing:

    Type    Two elements        One element        Empty
    List    [1, 2]              [1]                []
    Dict    {1:'a', 2:'b'}      {1:'a'}            {}
    Set     {1, 2}              {1}                set()

One of these things is not like the others...  One of these things just
doesn't belong...  Or is "regular enough that newcomers' guesses about
what to type are usually right" no longer a design consideration?

Thanks,
Greg


More information about the Python-3000 mailing list