try-reraise.py 283 Bytes
Newer Older
1
# Reraising last exception with raise w/o args
2
3
4
5
6
7
8
9
10
11
12

def f():
    try:
        raise ValueError("val", 3)
    except:
        raise

try:
    f()
except ValueError as e:
    print(repr(e))
13
14
15
16
17
18
19


# Can reraise only in except block
try:
    raise
except RuntimeError:
    print("RuntimeError")