rodrigosantosbr

[Python]Execute functions after interpreter termination

Feb 14th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

You can use ‘atexit’ module to execute functions at the time of Python interpreter termination.

import atexit

def sum():
  print(4+5)

def message():
  print(“Executing Now”)

atexit.register(sum)
atexit.register(message)

Output:

Executing Now
9
Add Comment
Please, Sign In to add comment