[Python-3000] sets in P3K?

Raymond Hettinger rhettinger at ewtllc.com
Tue May 2 21:05:06 CEST 2006

>That doesn't fix everybody's brain though. Given that sets are much
>less universally useful than dicts I don't think that dict should
>"give in".
Right. Changes to the {} notation for empty dicts should be off the 
table lest we have a lifetime of regrets.  Set literals are not worth 
committing atrocities elsewhere in the language.

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.

Also, FWIW, I think the current dict constructor is fine as-is.  No 
doubt that its API is fully-loaded, but it is very useful and not hard 
to learn.  Practicality wins here.


More information about the Python-3000 mailing list