user7778287
user7778287

Reputation: 369

Use overflow error as condition in Python?

I need to use an overflow error in Python as a condition. I.E. if the overflow error occurs then perform function b, rather than simply halting the program.

I can't find the right keywords to google if this is possible, can anyone point me in the right direction?

Upvotes: 0

Views: 187

Answers (1)

Netwave
Netwave

Reputation: 42678

Just use a try/except block:

try:
    raise OverflowError("Uuuups")
except OverflowError as e:
    do_some_stuff(e)

Here you have a live example

Upvotes: 1

Related Questions