[Python-Dev] Sets, Dictionaries

Steven D'Aprano steve at pearwood.info
Thu Mar 29 01:57:56 EDT 2018


Hi Julia, and welcome!

On Wed, Mar 28, 2018 at 09:14:53PM -0700, Julia Kim wrote:

> My suggestion is to change the syntax for creating an empty set and an 
> empty dictionary as following.
> 
> an_empty_set = {}
> an_empty_dictionary = {:}
> 
> It would seem to make more sense.

Indeed it would, and if sets had existed in Python since the beginning, 
that's probably exactly what we would have done. But unfortunately they 
didn't, and {} has meant an empty dict forever.

The requirement to keep backwards-compatibility is a very, very hard 
barrier to cross. I think we all acknowledge that it is sad and a little 
bit confusing that {} means a dict not a set, but it isn't sad or 
confusing enough to justify breaking millions of existing scripts and 
applications.

Not to mention the confusing transition period when the community would 
be using *both* standards at the same time, which could easily last ten 
years.

Given that, I think we just have to accept that having to use set() for 
the empty set instead of {} is a minor wart on the language that we're 
stuck with.

If you disagree, and think that you have a concrete plan that can make 
this transition work, we'll be happy to hear it, but you'll almost 
certainly need to write a PEP before it could be accepted.

https://www.python.org/dev/peps/


Thanks,

-- 
Steve


More information about the Python-Dev mailing list