If BLOCK raises an exception, the __exit__(type, value, traceback)() is called with the exception details
from __future__ import with_statement
class a(object):
def __enter__( self ):
return {"test":"OK"}
def __exit__( self, arg1, arg2, arg3 ):
print arg1, arg2, arg3
b = a()
with b:
1/0
<type ‘exceptions.ZeroDivisionError’> integer division or modulo by zero <traceback object at 0x009EE058>Если делать
Traceback (most recent call last):
File “python.py”, line 10, in <module>
1/0
ZeroDivisionError: integer division or modulo by zero
with b:
pass
О каких исключениях идёт речь?