Finding the variables (read or write)
Chris Angelico
rosuav at gmail.com
Mon Jan 14 16:28:28 EST 2013
On Tue, Jan 15, 2013 at 6:48 AM, <servekarimi at gmail.com> wrote:
> I'd like to develop a small debugging tool for python programs.In Dynamic Slicing How can I find the variables that are accessed in a statement? And find the type of access (read or write) for those variables (in Python).
> ### Write: A statement can change the program state.
> ### Read : A statement can read the program state .
> **For example in these 4 lines we have:
> (1) x = a+b => write{x} & read{a,b}
> (2) y=6 => write{y} & read{}
> (3) while(n>1) => write{} & read{n}
> (4) n=n-1 => write{n} & read{n}
An interesting question. What's your definition of "variable"? For
instance, what is written and what is read by this statement:
self.lst[2] += 4
Is "self.lst" considered a variable? (In C++ etc, this would be a
member function manipulating an instance variable.) Or is "self" the
variable? And in either case, was it written to? What about:
self.lst.append(self.lst[-1]+self.lst[-2])
(which might collect Fibonacci numbers)?
ChrisA
More information about the Python-list
mailing list