[Python-ideas] except expression

Jan Kaliszewski zuo at chopin.edu.pl
Sun Feb 16 23:45:12 CET 2014


16.02.2014 23:19, Chris Angelico wrote:

> On Mon, Feb 17, 2014 at 7:39 AM, Jan Kaliszewski <zuo at chopin.edu.pl> 
> wrote:
>> Sorry, I don't catch the point.  If I needed to use a complex
>> exception spec (a tuple-like) and/or a tuple as the "default"
>> expression -- I'd just do it:
>>
>>     some_io() except (FileNotFoundError: (1, 2, 3),
>>                       (ValueError, TypeError): 'spam')
>>
>> I see no ambiguity here.
>
> Maybe not, but the only thing preventing that from parsing as a tuple
> containing two tuples is the colon a bit further along. That might be
> sufficient for the lexer (in the same way that, for instance, 
> function
> arguments can contain tuples), but I suspect it may be confusing for
> humans.

IMHO, not more confusing than a dict literal containing tuple literals
as keys or values...

Cheers.
*j



More information about the Python-ideas mailing list