Is there a way in python\pydev to see and access instances of a certain class while debugging?
For instance, if I define SomeClass and various modules in a single python interpreter script instantiate this class, is there a way to see how many such instances exist in the interpreter and to access their attributes in a central fashion, without coercing the code to hold references to them from a single location (such as the module where the class is defined)?
Is there a way in python\pydev to see and access instances of a certain
Share
You could find all such objects using gc.get_objects():
For example, if you define
Fooclass in moduleothermod.py:then you can count all instances of
Fooin scriptscript.pylike this:Caveat:
gc.get_objectsdoes not track instances of atomic types (likeintorstr), but it sounds like that is not the kind of object you want to track.