How to debug python + curses? [was: RE: Applying winpdb_reborn]
pjfarley3 at earthlink.net
pjfarley3 at earthlink.net
Tue Jun 1 00:52:32 EDT 2021
> -----Original Message-----
> From: Chris Angelico <rosuav at gmail.com>
> Sent: Sunday, May 30, 2021 5:47 PM
> To: Python <python-list at python.org>
> Subject: Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]
>
<Snipped>
> Never had this problem with curses per se (partly because I've used it very little),
> but a more general technique for debugging things that don't have a "normal"
> console is to create one via a pipe or file. The easiest way is something like:
>
> log = open("logfile.txt", "w")
> print(f"At this point, {foo=}", file=log, flush=True)
>
> Then, in a separate window - or even on a completely different machine, via SSH
> or equivalent - "tail -F logfile.txt" will be your console.
Thank Chris. Your method will certainly work, I just used the python logging facilities to do effectively the same thing, but it is a slower debugging process than having the ability to examine the program environment dynamically while it is actually executing but stopped at a chosen breakpoint.
Using tail on a Windows system requires non-native facilities (though gnuwin32's tail does a creditable job).
I'm used to having the facilities of an interactive debugger available in my day job (not on *ix or Windows systems though), I just thought that interactive debugging would be more the rule than the exception here too.
Peter
--
More information about the Python-list
mailing list