import gc


class Foo:
    pass
f1 = Foo()
[o for o in gc.get_objects() if isinstance(o, Foo)]
f2 = Foo()
[o for o in gc.get_objects() if isinstance(o, Foo)]
How do I list all instantiated objects in Python?