hopflink
hopflink

Reputation: 173

How can I set what will be done when my python program terminates with error?

Is there any method to set certain action when my python program ends abruptly? Especially I want to delete a folder and leave a log what was the error using logging module.

Upvotes: 0

Views: 31

Answers (2)

Hamish
Hamish

Reputation: 513

You can use error handling, particuarly using the Try, Except statements.

Upvotes: 0

John Gordon
John Gordon

Reputation: 33345

Depending on what you mean by "ends abruptly", the atexit module https://docs.python.org/2/library/atexit.html may be what you are looking for.

Upvotes: 1

Related Questions