[Python-ideas] except expression
Jan Kaliszewski
zuo at chopin.edu.pl
Fri Feb 14 22:29:26 CET 2014
13.02.2014 13:50, Nick Coghlan wrote:
> Some of the specific syntactic proposals:
>
> x = op() except default if Exception
> x = op() except default for Exception
> x = op() except default from Exception
> x = op() except Exception return default
>
> x = op() except exc.attr if Exception as exc
> x = op() except exc.attr for Exception as exc
> x = op() except exc.attr from Exception as exc
> x = op() except Exception as exc return exc.attr
Please append also my proposal from another branch of this thread:
> 1. Simple Variant:
>
> get_it() except (IndexError: None)
>
> 2. Variant with 'as':
>
> get_it() except (OSError as exc: exc.errno)
>
> 3. Variant with multiple exceptions:
>
> get_it() except (FileNotFound: 0,
> OSError as exc: exc.errno,
> Exception: None)
Cheers.
*j
More information about the Python-ideas
mailing list