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

Ron Adam rrr at ronadam.com
Tue Jun 16 16:27:46 CEST 2009

Ben Finney wrote:
> Carl Johnson
> <cmjohnson.mailinglist at gmail.com> writes:
>> we could introduce an empty set-literal and an odict-literal, and add
>> a more explicit form to replace the existing set literal.
> What do you mean by “more explicit”? The existing set literal syntax
> is quite explicit.
>> 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 don't think that word “explicit” means what you think it means.

I think Carl is thinking that it is more concise and easier to read.

When you read OrderedDict([('a', '1'),('b', '2'), ('c', '3')]),  your mind 
is parsing  *Ordered Dictionary from list of these three tuples*.

Whebn you read *o{'a':'1', 'b':'2', 'c':'3'}*, your mind does not have the 
extra noise of converting the argument list of the constructor.

I think it really depends on how often ordered dictionaries literals will 
be used weather or not it is worth doing.  It also uses about 30% to 50% 
less keystrokes.


More information about the Python-ideas mailing list