import random
# Then ever you're not sure that some piece of code will or will not work out
# but you still need to perform some actions afterwords like: free resources,
# unluck screen, send message, what ever... You need some kind of finalizer, so
# python give you this. Behold! `finally` statement!
try:
t = random.randint(0, 1000)
# We're kind a not sure...
if t < 500:
raise KeyboardInterrupt
else:
print "Pure win!"
# But finalizing action will happens no maters what.
finally:
print "Just before to say goodbye!"