On Mon, Aug 24, 2020 at 10:58:13AM +0200, Alex Hall wrote:

> {a:b} is a dict, {(a:b)} is a set containing one slice.

What's `{a: b: c: d, x: y}`? Typo or key with a slice value?

I know that any syntax can contain typos, but we generally try to avoid 
syntax which silently swallows such syntactic typos. The only one I can 
think of is implicit string concatenation:

    values = ['spam', 'eggs' 'NOBODY expects the Spanish Inquisition',
              'Ethel the Aardvark Goes Quantity Surveying']

is probably supposed to have four items, not three :-)

But implicit string concatentation is useful enough that (in my opinion) 
it is worth keeping it around despite the occasional whoops moment.

Admittedly slicing is already vulnerable to that:

    obj[a:b,c]  # two items or typo for an extended slice?

but I'm not sure that slice literals outside of subscripts is useful at 
all, let alone useful enough to allow this sort of silent error outside 
of subscripts.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BOFVUJU4NAHUPVXWUW2JDZZJP33WN7M6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to