[Python-3000] set literals

tomer filiba tomerfiliba at gmail.com
Fri Jul 7 22:19:52 CEST 2006


i had this idea -- since quoted literals can be prefixed by a letter
that alters their meaning, why not use the same semantics
with curly braces?

"hello" -- byte string literal
r"hello" -- unescaped byte string literal
u"hello" -- unicode string literal

{1:2, 3:4, 5:6} -- dict literal
s{1, 2, 3} -- set literal

{} -- empty dict literal
s{} - empty set literal

this is more explicit, as {1:2} as {1,2} are too similar imo, and also
solves the no-literal-for-empty-set issue that has been discussed
at length.

this should only be a slight change to the parser, and is a syntax
error today, so there shouldn't be any backward-compat issues.

it may look strange at first (at least it me), but it's just a matter of
getting used to -- it's not any stranger than u"hello"


-tomer


More information about the Python-3000 mailing list