import gc class myObj: a = [] b = False global o o = myObj() def test(name = False): global o if name: print("\nTesting after %s:" % name) gc.collect() o = myObj() print(o.a) print(o.b) o.a.append(True) o.a.append(3.141) o.a.append("I'm still here!") o.b = True print("\nInitial values:") test() del o test('object deletion') # result: array populated if 0: del o.a # AttributeError: myObj instance has no attribute 'a' del o test('array deletion') # result: n/a o.a = [] test('array re-init') # result: array populated for item in o.a: del item test('array per-item deletion') # result: array populated while len(o.a): o.a.pop() test('pop()') # result: array clear