[Python-ideas] syntax for set

MRAB python at mrabarnett.plus.com
Mon Nov 15 21:52:44 CET 2010

On 15/11/2010 20:34, Alexandre Conrad wrote:
> 2010/11/15 spir<denis.spir at gmail.com>:
>> [sorry, sent unintentionally]
>> On Mon, 15 Nov 2010 11:02:53 -0800
>> Guido van Rossum<guido at python.org>  wrote:
>>> There is nothing obvious about {:} for the empty dictionary. :-)
> {:} for empty dict could make some sense. If that is ever accepted, it
> will probably go in Python 4 as the change is so important.
>> Anyone votes for {/} meaning empty set?
> -1.
> List, tuple and dict have their own literals. Now sets shares dict's
> literals. That's why I proposed using a new container literal for
> sets, such as<1, 2, 3>  where an empty set would be<>. As lists and
> tuples are the mutable/immutable pairs, I thought we could have
> literals for frozenset as well. But I can no longer find available
> opening/closing symbols on my keyboard. Darn.
> I also thought about doubling braces, such as {{1, 2, 3}}, then {{}}
> for an empty set would work. (and probably break some templating
> engines out there ;)). But it conflicts with "a dict in a set" (which
> is unhashable anyway, but that's not a valid reason).
I set is unordered, like a dict, so using {...} for both kind of makes
sense, with the entries in the dict literal consisting of pairs
separated by ":", which is why I would've liked {:}.

Let's leave <...> for some future use. (Could they have been used for
tuples, thus avoiding all the discussions about how "," builds tuples,
apart from the empty tuple? :-))

More information about the Python-ideas mailing list