fork download
  1. import gc
  2.  
  3. class Foo:
  4. pass
  5.  
  6. x = Foo()
  7. print('No dict in', gc.get_referents(x))
  8. x.__dict__
  9. print("Now there's a dict:", gc.get_referents(x))
Success #stdin #stdout 0.01s 27656KB
stdin
Standard input is empty
stdout
No dict in [<class '__main__.Foo'>]
Now there's a dict: [{}, <class '__main__.Foo'>]