[Python-ideas] Possible method of distinguishing between set-literals, dict-literals, and odict-literals

Carl Johnson cmjohnson.mailinglist at gmail.com
Tue Jun 16 13:54:10 CEST 2009

I thought of this in the shower. It might not be a good idea, but I'd
like to hear what other people think. On analogy with b"", r"", etc.
we could introduce an empty set-literal and an odict-literal, and add
a more explicit form to replace the existing set literal. s{} could be
the empty set, o{} could be an empty odict, and we could leave {}
alone as the form for dicts. So, an odict literal would look like
o{'a':'1', 'b':'2', 'c':'3'} instead of OrderedDict([('a', '1'), ('b',
'2'), ('c', '3')]). And the set {'a', 'c', 'b'} could (optionally?)
have a little s{'a', 'c', 'b'} to make it more explicit that this is a
set, not a dict.

I suppose if we wanted to get crazy, we could also have a frozenset
literal, fs{}…

So what do people think? Is this too ugly to do? Does it confuse users
who are used to C-style braces? Or is it a logical extension of the
b"", r"", etc. system that could help make things follow EIBI better?

-- Carl Johnson

More information about the Python-ideas mailing list