class Bar(object):
    foo = Foo()

def __init__(self):
    print('Bar init running')

def __del__(self):
    print('Destructor Bar')

def f():
    bar_obj = Bar()
f()
del Bar
Python static variable deallocation