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


Groups > comp.lang.python > #57578

Debugging decorator

Date 2013-10-26 02:55 +0300
Subject Debugging decorator
From Yaşar Arabacı <yasar11732@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1561.1382745652.18130.python-list@python.org> (permalink)

Show all headers | 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