[Python-ideas] Debugging: some problems and possible solutions

Samuel Colvin S at muelcolvin.com
Fri Oct 5 11:57:52 EDT 2018

> So I'm suggesting a new built-in debug() function as an easy and
> consistent way to write out debugging information.

Python definitely needs a dedicated debug print command. Since
"debug" is take in 3.7, perhaps "debug.print" would work?

I've built python devtools with has such a command:


(I'm not trying to promote devtools, just demonstrate what is possible.)

The packge needs a little work but it's already extremely useful,
I use it all day every day.

A few things with devtools' debug does:
* pretty printing of objects (like pprint but IMHO clearer)
* coloured output of objects
* extra info about objects, eg. length, type etc.
* line numbers and function names where debug() was called
* names of the varible (or expression) which is being printed

It would be difficult to fully integrate a package like this into
the standard lib since it relies on pygments for colouring output,
but not impossible.

Is this the kind of thing you were thinking about?

Samuel Colvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181005/6da351fc/attachment.html>

More information about the Python-ideas mailing list