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

Ben Finney ben+python at benfinney.id.au
Tue Jun 16 15:55:40 CEST 2009


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.

> So what do people think? Is this too ugly to do?

You haven't really identified a problem that is solved by this. And yes,
I think it's significantly uglier than the existing syntax.

> 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?

(Presuming you mean “EIBTI”, for “Explicit Is Better Than Implicit”.)

I don't see anything implicit about the following forms:

    set()
    OrderedDict()
    frozenset()

So I think you're trying to achieve something else other than
“explicit”, but I don't know what it is, nor what the problem is that
needs addressing.

-- 
 \           “Never express yourself more clearly than you are able to |
  `\                                               think.” —Niels Bohr |
_o__)                                                                  |
Ben Finney




More information about the Python-ideas mailing list