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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With