[Python-ideas] syntax for set
steve at pearwood.info
Mon Nov 15 23:52:47 CET 2010
> 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? :-))
But comma *is* the tuple-building operator. This allows us to write:
x, y = p, q
return x, y, z
instead of being forced to including brackets. Are you suggesting that
commas should be optional?
t = <x y z>
This will be an unfortunate source of errors unless we also drop
implicit string concatenation (which is too useful to drop!)
t = <"a" "b" 2> # 2-tuple, not 3
As for using < > for tuples, that leads to such horrors as:
if <a, b> < <c, d>: ...
elif <b, a> > <d, c>: ...
which is too ghastly for words.
Now, can we please stop bike-shedding over something so trivial as a way
to write an empty set as a literal? What's wrong with just writing set()?
More information about the Python-ideas