Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML debug pretty-printing for Python

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.

like image 259
threewestwinds Avatar asked Dec 02 '11 06:12

threewestwinds


People also ask

How to pretty print in Python?

How To Pretty Print in Python. Start using the pprint library | by Jonathan Hsu | Better Programming Everybody needs to see the output of variables, calculations, and the progress through loops—one of the first functions you will learn to use is print (). It’s easy to stop here. The function gets the job done — sort of.

How do you debug print in Python?

debugprint can also pretty-print nested lists, tuples, and mixed JSON by default - essentially anything that can be handled by the standard library pprint module. Import into every module where you want to do debug printing, then create an instance of the Debug class for that module.

What are the disadvantages of using print() function for debugging?

One of the biggest issue when using the print () function for debugging is that there are too many of them. It is very common that we have them everywhere when we finished the development. Then, it would be a disaster if we want to clean our code to remove them.

How to write pretty print JSON data to a file in Python?

Write Pretty Print JSON data to file To write a Python object as JSON formatted data into a file, json.dump () method is used. Like json.dumps () method, it has the indents and separator parameters to write beautified JSON.


Video Answer


1 Answers

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.

like image 72
threewestwinds Avatar answered Oct 21 '22 23:10

threewestwinds