Time we switched to unicode? (was Explanation of this Python language feature?)

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Mar 25 14:36:36 CET 2014


On Tue, 25 Mar 2014 08:21:19 -0400, Roy Smith wrote:

> In article <mailman.8511.1395743071.18130.python-list at python.org>,
>  Antoon Pardon <antoon.pardon at rece.vub.ac.be> wrote:
> 
>> Come on. The problem isn't that both set and dictionary literal use
>> braces. That doesn't seem to be a problem in python3. The only question
>> was what should {} represent and how do we get an empty collection of
>> the other kind. If {} had been an empty set, dict() could have been
>> used for an empty dictionary is {:} had been unacceptable.
> 
> By analogy to tuples, it could have been {,}.

An empty tuple is (), not (,). {,} is just making up random syntax almost 
unrelated to anything else. One might as well used {?} or {+}.

If Python 3 had introduced {} to mean the empty set, I *guarantee* that 
right now people would be arguing that "Python 3 could have used {} for 
the empty dict, and used set() for the empty set" -- and very likely the 
same people now arguing the opposite.

Yes, Python could have changed the meaning of {} to mean the empty set. 
But you know what? The empty set is not that important. Sets are not 
fundamental to Python. Python didn't even have sets until 2.3, and at 
first they were just a standard library module, not even built-in. Dicts, 
on the other hand, are fundamental to Python. They are used everywhere. 
Python is, in a very real sense, built on dicts, not sets. You can 
implement sets starting from dicts, but not the other way around: dicts 
are more fundamental than sets.

I'm sure it is awfully impressive that mathematicians can derive the laws 
of integer maths starting only from the empty set ∅, but as far as 
programming goes that's not a very useful thing. Dicts are much more 
important, and they are much more commonly used.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/



More information about the Python-list mailing list