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


Groups > comp.lang.python > #57578 > unrolled thread

Debugging decorator

Started byYaşar Arabacı <yasar11732@gmail.com>
First post2013-10-26 02:55 +0300
Last post2013-10-26 02:55 +0300
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#57578 — Debugging decorator

FromYaşar Arabacı <yasar11732@gmail.com>
Date2013-10-26 02:55 +0300
SubjectDebugging decorator
Message-ID<mailman.1561.1382745652.18130.python-list@python.org>
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/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web