On Thu, Jul 05, 2018 at 08:52:24PM +0300, Ivan Pozdeev via Python-Dev wrote:

> * Same goes for `except`: doesn't accept expressions, same semantic.


py> def make_exception(arg):
...     return ValueError if arg else TypeError
...
py> expr = [make_exception]
py> try:
...     1+"1"
... except expr[0](None) as err:
...     print("caught", type(err))
...     print(err)
...
caught <class 'TypeError'>
unsupported operand type(s) for +: 'int' and 'str'


-- 
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to