import atexit

def my_cleanup(name):
    print('my_cleanup({})'.format(name))

if False:
    atexit.register(my_cleanup, 'never registered')

"""
unregistering a function that is not registered previously
incurs no errors.

? why?

Because it silently ignores unknown callbacks, 
unregister() can be used even when the
sequence of registrations is not known.
"""
atexit.unregister(my_cleanup)
7e7c0f8221f2b8a1dedf12e8314a0cd174544471
<mask token>

<mask token>


def my_cleanup(name):
    print('my_cleanup({})'.format(name))


<mask token>

<mask token>


def my_cleanup(name):
    print('my_cleanup({})'.format(name))


if False:
    atexit.register(my_cleanup, 'never registered')
<mask token>
atexit.unregister(my_cleanup)

import atexit


def my_cleanup(name):
    print('my_cleanup({})'.format(name))


if False:
    atexit.register(my_cleanup, 'never registered')
<mask token>
atexit.unregister(my_cleanup)

import atexit

def my_cleanup(name):
    print('my_cleanup({})'.format(name))

if False:
    atexit.register(my_cleanup, 'never registered')

"""
unregistering a function that is not registered previously
incurs no errors.

? why?

Because it silently ignores unknown callbacks, 
unregister() can be used even when the
sequence of registrations is not known.
"""
atexit.unregister(my_cleanup)