[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Tue Feb 18 08:22:12 CET 2014


On Tue, Feb 18, 2014 at 6:12 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Not in general, but in situations where you need the
> conciseness of an except-expression?
>
> The examples in the PEP all seem to be variations on
>
>
>    value = next(it) except StopIteration as e: e.args[0]
>
> which seems a bit contrived. It's hard to think of a
> situation where you'd want to treat the yielded values
> and the return value of a generator in the same way.

There's another one based on retrieving a document or its error text,
and showing that to a human. Beyond that, I really need other people
to make suggestions; there are those here who spend 99% of their time
writing Python code and know all the ins and outs of the libraries,
but I am not them.

ChrisA


More information about the Python-ideas mailing list