[Python-ideas] except expression

Jan Kaliszewski zuo at chopin.edu.pl
Wed Feb 19 02:16:01 CET 2014


18.02.2014 21:55, Chris Angelico wrote:

> Script:
> https://github.com/Rosuav/ExceptExpr/blob/master/find_except_expr.py
> Output:
> https://github.com/Rosuav/ExceptExpr/blob/master/candidates.txt
> Annotated examples:
> https://github.com/Rosuav/ExceptExpr/blob/master/examples.py

Excellent! :)

One more minor motivating case:

     q = queue.Queue(maxsize=10)
     ...
     item = q.get_nowait() except Full: default

(in case of a list you could check its length to avoid catching
exception; but Queue's usage cases are typically multi-threading
-related so the "check and then get" way is not an option then)

Cheers.
*j



More information about the Python-ideas mailing list