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


Groups > comp.lang.python > #36821

Re: Finding the variables (read or write)

References <46c8a630-de27-41dc-8b8b-1951ba747447@googlegroups.com>
Date 2013-01-15 08:28 +1100
Subject Re: Finding the variables (read or write)
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.520.1358198911.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jan 15, 2013 at 6:48 AM,  <servekarimi@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Finding the variables (read or write) servekarimi@gmail.com - 2013-01-14 11:48 -0800
  Re: Finding the variables (read or write) Chris Angelico <rosuav@gmail.com> - 2013-01-15 08:28 +1100
  Re: Finding the variables (read or write) Chris Kaynor <ckaynor@zindagigames.com> - 2013-01-14 13:37 -0800
  Re: Finding the variables (read or write) Terry Reedy <tjreedy@udel.edu> - 2013-01-14 16:42 -0500
  Re: Finding the variables (read or write) Chris Angelico <rosuav@gmail.com> - 2013-01-15 08:46 +1100

csiph-web