Say that in the python shell (IDLE) I have defined some classes, functions, variables. Also created objects of the classes. Then I deleted some of the objects and created some others. At a later point in time, how can I get to know what are the currently active objects, variables, and methods definitions active in the memory?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Try
globals()
The function
gc.get_objects()
will not find all objects, e.g. numpy arrays will not be found.You will need a function that expands all objects, as explained here
Now we should be able to find most objects
Yes.
Not that you'll find that useful. There is a lot of them. :-) Over 4000 just when you start Python.
Possibly a bit more useful is all the variables active locally:
And the one active globally:
(Note that "globally" in Python isn't really global as such. For that, you need the
gc.get_objects()
above, and that you are unlikely to ever find useful, as mentioned).