Class count instances - decrease also (destructor: __del__)



examples/oop/counter_decrease.py
class Thing:
    count = 0
    def __init__(self):
        Thing.count += 1
    def __del__(self):
        Thing.count -= 1

def main():
    print(Thing.count)  # 0
    t1 = Thing()
    print(Thing.count)  # 1
    t2 = Thing()
    print(Thing.count)  # 2
    t3 = Thing()
    print(Thing.count)  # 3
    t3 = None
    print(Thing.count)  # 2

main()
print(Thing.count)  # 0