[Python-ideas] except expression

Andrew Barnert abarnert at yahoo.com
Mon Feb 17 18:51:56 CET 2014


On Feb 17, 2014, at 7:08, Chris Angelico <rosuav at gmail.com> wrote:

> On Tue, Feb 18, 2014 at 2:00 AM, M.-A. Lemburg <mal at egenix.com> wrote:
>> x = 1, 2,
>> x = {1:2,}
> 
> Actually, a more confusing pair than those is this:
> 
> x = {1,2,}
> x = {1:2,}
> 
> In terms of the "grit on the screen syntax" problem, this one is at
> some risk. My currently-preferred proposal for exceptions makes good
> use of the 'except' keyword, so it should be fairly clear what's going
> on.

That's just because set displays are somewhat degenerate. With 0 elements they are impossible to distinguish from dict displays are therefore illegal; with 1 or 2 elements they can be hard for humans over 30 to distinguish from dict displays (especially without PEP 8-style proper spacing, as in your examples) and are therefore a bit risky; it's just a lesser version of the same problem.


More information about the Python-ideas mailing list