Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Real Users are afraid they'll break the machine -- but they're never afraid to break your face.


devel / comp.lang.python / Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]

SubjectAuthor
o Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]Alan Gauld

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

<mailman.441.1622407657.3087.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=13459&group=comp.lang.python#13459

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: alan.ga...@yahoo.co.uk (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]
Date: Sun, 30 May 2021 21:37:53 +0100
Lines: 36
Message-ID: <mailman.441.1622407657.3087.python-list@python.org>
References: <000001d75578$f4ced0b0$de6c7210$@earthlink.net>
<s90t32$112e$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de Zz3XSZ87BqMvPYjiVe+MnwkxzaXiU9MYLbWpxSmDh5Uw==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04;
'subject:python': 0.06; 'debug': 0.07; 'debugging': 0.07;
'(python': 0.09; 'alone.': 0.09; 'keen': 0.09; 'message-
id:@ciao.gmane.io': 0.09; 'module.': 0.09;
'received:ciao.gmane.io': 0.09; 'received:gmane.io': 0.09;
'received:list': 0.09; 'window.': 0.09; '%s"': 0.16; 'flickr':
0.16; 'from:addr:alan.gauld': 0.16; 'from:name:alan gauld': 0.16;
'photo-blog': 0.16; 'received:116.202': 0.16;
'received:116.202.254': 0.16; 'received:116.202.254.214': 0.16;
'subject:debug': 0.16; 'url-ip:79.170.44.132/32': 0.16; 'url-
ip:79.170.44/24': 0.16; 'url-ip:79.170/16': 0.16; 'url-ip:79/8':
0.16; 'url:alan-g': 0.16; 'url:alan_gauld': 0.16;
'url:alangauldphotos': 0.16; 'wrote:': 0.16; 'python': 0.16;
'figure': 0.18; 'uses': 0.19; 'url:amazon': 0.20; 'subject:How':
0.22; 'anyone': 0.23; 'to:addr:python-list': 0.23; 'code': 0.24;
'tried': 0.26; 'else': 0.27; 'header:User-Agent:1': 0.31; 'but':
0.31; 'approach': 0.31; 'script': 0.32; "i'm": 0.32; 'window':
0.32; 'program': 0.33; 'header:In-Reply-To:1': 0.33; 'year': 0.35;
'bar': 0.35; 'at:': 0.37; 'way': 0.37; 'author': 0.38;
'something': 0.38; 'use': 0.38; 'main': 0.40; 'could': 0.40;
'skip:w 10': 0.61; 'here': 0.62; 'follow': 0.63; 'site': 0.69;
'url:author': 0.69; 'received:116': 0.71; 'subject:]': 0.71;
'subject:skip:w 10': 0.77; 'biggest': 0.84; 'positioned': 0.84;
'retained': 0.91
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
In-Reply-To: <000001d75578$f4ced0b0$de6c7210$@earthlink.net>
Content-Language: en-GB
X-Mailman-Approved-At: Sun, 30 May 2021 16:47:34 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <s90t32$112e$1@ciao.gmane.io>
X-Mailman-Original-References: <000001d75578$f4ced0b0$de6c7210$@earthlink.net>
 by: Alan Gauld - Sun, 30 May 2021 20:37 UTC

On 30/05/2021 18:26, pjfarley3@earthlink.net wrote:
> I tried winpdb-reborn some time last year on my Win10 system (python 3.8.3
> at that time), but could not figure out how to use it to debug a python
> script that uses the curses module.

You are not alone. debugging curses is one of the biggest obstacles to
its use.

My approach is to define a status line at the bottom of my program and
write print statements into that window. Something like:

def main(stdwin):
appwin = curses.newwin(...) # LINES-1 high
status = curses.newwin(...) # 1 line high positioned on bottom
# more code here
status.addstr(0,0, "Value of foo = %s" % foo)

curses.wrapper(main)

After debugging the status window can either be retained as an
application status bar or removed and the main window
enlarged by one line...

If anyone else has found a better way to debug curses code I'm
also keen to hear!

HTH
--
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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor