How to debug python + curses? [was: RE: Applying winpdb_reborn]

Alan Gauld alan.gauld at yahoo.co.uk
Tue Jun 1 14:48:05 EDT 2021


On 31/05/2021 16:16, Grant Edwards wrote:
> On 2021-05-30, Alan Gauld via Python-list <python-list at python.org> wrote:

>> You are not alone. debugging curses is one of the biggest obstacles to
>> its use.
> 
> Can't you just run the debugger in a different window and attach to
> the process you want to debug? That's how one uses a debugger with
> curses apps written in C/C++. 

That's how we did it when I used curses on VMS/Unix using C.

But I confess I didn't think you could attach any python
debugger to another python session?

> Or I add debugging printf calls which
> write to stderr and redirect stderr to a file.

I do use logging sometimes but its not as immediate
as seeing the messages in the application as you run it.

>> My approach is to define a status line at the bottom of my program and
>> write print statements into that window. Something like:
> 
> Why not just use the standard python logging facility and log to a
> file or another terminal window?

I find the immediacy of an in-window message much easier. Its like using
print() statements in a regular CLI application. Its there in front of
you, no other terminals to look at.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list