Destructor: __del__



examples/oop/destructor.py
class Thing:
    def __init__(self):
        print('__init__')
    def __del__(self):
        print('__del__')

def main():
    a = Thing()
    print('in main - after')

main()
print('after main')

__init__
in main - after
__del__
after main