Python object inspector?

other than using a fully integrated IDE with a debugger for python (like Eclipse), is there a little tool to achieve this:

  • when starting the program, I want to be able to hook it (similar to inserting a print statement) and call a window with an object inspector (tree view)
  • after closing the window, the program should resume

No need to polish, not even be absolutely stable, it could be introspection example code for some widget library like wx. Regardless of the platform, it would be nice (not a PyObjC program, or something similar on Windows).

Any ideas?

Edit: Yes, I know about pdb, but I'm looking for a graphical tree of all current objects.

However, here's a good introduction to how to use pdb (in this case in Django): pdb + Django

+2


source to share


5 answers


Winpdb - it is independent of the platform graphical GPL-Python debugger with the object inspector.

It supports network remote debugging, multithreading, namespace modification, inline debugging, encrypted communication, and is 20x faster than pdb.

Some other features:



  • GPL license. Winpdb is free software.
  • Compatible with CPython 2.3 up to 2.6 and Python 3000
  • Compatible with wxPython 2.6 to 2.8
  • Platform independent and tested on Ubuntu Jaunty and Windows XP.
  • User Interfaces: rpdb2 is console based, while winpdb requires wxPython 2.6 or newer.

Here is a screenshot that shows the local object tree in the upper left corner.

Screenshot
(source: winpdb.org )

+5


source


pdb is incomplete, it runs in the console, but this is the standard way to debug in Python programs.

Paste this where you want to stop:



import pdb;pdb.set_trace() 

      

you will receive a prompt for standard output.

+3


source


If a commercial solution is acceptable, Wingware might be the answer to the OP's wishes (Wingware has free versions, but I don't think they have the full debugging power it requires, which the paid versions provide).

+1


source


Python Debugging Techniques is worth reading. and his Reddit comment is worth reading too. I actually found some good debugging tricks from Brian's comment. such as this comment and this comment .
Of course WingIDE is cool (for general Python coding and debugging Python code) and I use it every day. unlucky for WingIDE still can't embed IPython at this time.

+1


source


You can use ipython with instruction %debug

. Once your code is out of order, you can add breakpoints, see objects, etc. A very crude way to start the debugger is raise Exception

in some line of your code, run it in ipython, type %debug

when it crashes.

0


source







All Articles