[Tutor] Program Slicing / Trace

Jojo Mwebaze jojo.mwebaze at gmail.com
Thu Jun 18 16:37:27 CEST 2009


Hi Tutor

The problem i have is to see which statements modify my data at execution
time without referring to the code. Referring to the code is difficult esp
because of branching. You can never tell before hand which branch execution
will follow.

e.g in the example below, statements 1, 2, 5,7 and 10 modify my data and are
the ones i would like to trace during run time. However the other statements
do not change my data so am not interested in them.

How can this be achieved during execution? Not sure if the traceback module
can be helpful here!

Cheers

Jojo.

===========================

def myfunction():
1.    num1= 20 #statement 1
2.    num2 = 30 #statement 2
3.    somelist= [ ]  #statement 3
4.    if (num1 < num2):
5.          num2 = num2 * 20 #statement 3
6.    else:
7         num2 = num1 + num2 #statement 3
8.    mylist = [num1, num2] #statement 4
9.    for items in mylist:
10.       somelist.append( math.sqrt(item) + math.log(item)) #statement 5
11.   return somelist
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090618/2426a164/attachment.htm>


More information about the Tutor mailing list