HTML debug pretty-printing for Python
Asked Answered
U

2

6

After using the excellent Krumo package for PHP (perhaps most famous for its use in Drupal), I was wondering if there is something similar for Python.

Specifically, I'm looking for a package that does the following: turns arbitrary (or almost arbitrary) Python variables into themed HTML/CSS. Javascript component to collapse the various elements is preferred, but easy enough to write myself if necessary.

Is such a module available? I'd prefer something standalone, but if this only exists as part of another web framework, it would still be a good starting point.

Unlay answered 2/12, 2011 at 6:23 Comment(0)
U
4

Since I was unable to find any existing libraries, I wrote Pymo. It functions very similarly to Krumo, rendering any Python variable into html which can be printed or saved to a file for viewing in a web browser, with javascript and CSS to make it readable.

Please take a look at it and submit bug reports or feature requests if it helps you out.

Unlay answered 12/12, 2011 at 8:46 Comment(0)
B
0

Maybe cgitb is what your looking for:

The cgitb module provides a special exception handler for Python scripts. (Its name is a bit misleading. It was originally designed to display extensive traceback information in HTML for CGI scripts. It was later generalized to also display this information in plain text.) After this module is activated, if an uncaught exception occurs, a detailed, formatted report will be displayed. The report includes a traceback showing excerpts of the source code for each level, as well as the values of the arguments and local variables to currently running functions, to help you debug the problem. Optionally, you can save this information to a file instead of sending it to the browser.

Backbreaker answered 2/12, 2011 at 7:54 Comment(1)
I hadn't seen that module before - thanks for the pointer. But it doesn't do what I'm looking for. I want to print variables, rather than tracebacks - think "pickle into HTML".Unlay

© 2022 - 2024 — McMap. All rights reserved.