Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57578

Debugging decorator

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <yasar11732@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'debugging.': 0.09; 'statements': 0.09; 'url:github': 0.09; 'def': 0.12; 'wrote': 0.14; 'ast': 0.16; 'inserting': 0.16; 'nodes': 0.16; 'rewriting': 0.16; 'think?': 0.16; 'trying': 0.19; 'print': 0.22; 'helpful': 0.24; 'people,': 0.24; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'received:google.com': 0.35; 'returning': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'deleting': 0.60; 'new': 0.61; '144': 0.84; 'from:charset:iso-8859-9': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=9uoq+XtXbCrWaPUBjujMw+QuUNJnIAkPta37eJYTB0c=; b=PSd0AbFMfz+w9qSN+9GagGntSsBbaseUaCrtOkzaN9x1YJJnrH5jlDx3mbjKluyD9p b22myYpIkGLUTRiqJ7M5VXrbG2o3zLC4GPFNERbG0uTotzd8Qa1wxzNmDEpgnXdHeIbg SDZK9Z0oc5L1bgKMrtx/N8SD/zQYgOlkrfpaRWLyXduVU6ajbzGlyvio8AJEB/fp/xfC x01ThzZUaF0HaTI8qCSuRg5OL4IUQLfeOzYkSlSOrpktM5DDTp2fxVFhg4HKNRTY2YJe QT01EXp1huQr08TakuocQypgDLY09RgqMIeAqtxVTGrAjD2c01c6AGVMgpmSr9VlFGyx 993g==
MIME-Version 1.0
X-Received by 10.205.35.15 with SMTP id su15mr3804773bkb.21.1382745323740; Fri, 25 Oct 2013 16:55:23 -0700 (PDT)
Date Sat, 26 Oct 2013 02:55:23 +0300
Subject Debugging decorator
From Yaşar Arabacı <yasar11732@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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 <http://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>
Newsgroups comp.lang.python
Message-ID <mailman.1561.1382745652.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382745652 news.xs4all.nl 15913 [2001:888:2000:d::a6]:53148
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57578

Show key headers only | View raw


Hi people,

I wrote this decorator: https://gist.github.com/yasar11732/7163528

When this code executes:

    @debugging
    def myfunc(a, b, c, d = 48):
        a = 129
        return a + b

    print myfunc(12,15,17)

This is printed:

    function myfunc called
    a 12
    c 17
    b 15
    d 48
    assigned new value to a: 129
    returning 144
   144

I think I can be used instead of inserting and deleting print
statements when trying to see what is
passed to a function and what is assingned to what etc. I think it can
be helpful during debugging.

It works by rewriting ast of the function and inserting print nodes in it.

What do you think?


-- 
http://ysar.net/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Debugging decorator Yaşar Arabacı <yasar11732@gmail.com> - 2013-10-26 02:55 +0300

csiph-web