Debugging decorator

Y

Yaþar Arabacý

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top