[Python-ideas] syntax for set

Alexandre Conrad alexandre.conrad at gmail.com
Mon Nov 15 04:15:03 CET 2010


I am sure this has come up before and if it doesn't exist I believe
there is a good reason for it. Anyway, here's my thought: how about
having a syntax representation for sets? A mix of a dict and
list/tuple syntax would make the most sense, such as:

>>> isinstance({"foo", "bar"}, set)

The problem here is: how to represent an empty set as {} would
conflict with the dict repr. Then how about using a brand new
"container" syntax that wouldn't conflict with existing ones?

>>> <"foo", "bar"> == set(("foo", "bar"))

>>> <> == set()

Alex | twitter.com/alexconrad

More information about the Python-ideas mailing list