Snippets Flashcards

1
Q

Ignore exception but print all callstack

A
try:
    ...
except Exception:
    import traceback
    traceback.print_exc()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Add custom text to exception

A
try:
    ...
except KeyError as exc:
    raise Exception('text') from exc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Nested f-string

A

f”Number {val : {prec} }”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly