On 25-03-14 05:14, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 2:56 PM, Rustom Mody <rustompm...@gmail.com >>> I don't know about the difference between {} in set theory and Python, >>> but the multiple uses of () actually boil down to two: >> In set theory {} makes sets >> In python {} makes dictionaries > That's a backward-compatibility issue. Braces in Python meant a > dictionary before it acquired a set type (at least, so I learned in > history class - I wasn't using Python back then), so empty braces have > to continue to mean empty dictionary.
No they didn't have to. With the transition to python3, the developers could have opted for empty braces to mean an empty set. And if they wanted a literal for an empty dictionary, they might have chosen {:}. Backward-compatibility was already broken so that wasn't an argument. > I sympathize with the confusion, > but short of confusing everyone terribly by changing dicts to use > something other than braces (maybe borrow Pike's mapping notation, ([ > ])??), I don't really see a solution. 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. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list