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


Groups > comp.lang.python > #36822

Re: Finding the variables (read or write)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ckaynor@zindagigames.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'debugging': 0.05; 'class,': 0.07; 'python': 0.09; '###': 0.09; 'def': 0.10; '(read': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'have:': 0.17; 'instance': 0.17; 'instance,': 0.17; 'test.': 0.17; 'variables': 0.17; '(in': 0.18; 'jan': 0.18; 'email addr:gmail.com&gt;': 0.20; 'question.': 0.20; 'to:name:python-list@python.org': 0.20; 'written': 0.20; "i'd": 0.22; 'example': 0.23; '&gt;': 0.23; '15,': 0.23; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'am,': 0.27; '(3)': 0.27; 'c++': 0.27; 'to?': 0.27; 'message- id:@mail.gmail.com': 0.27; 'lines': 0.28; 'chris': 0.28; 'python).': 0.29; 'url:mailman': 0.29; 'case,': 0.29; 'definition': 0.29; 'skip:_ 10': 0.29; 'skip:& 10': 0.29; 'class': 0.29; 'normally': 0.30; 'function': 0.30; 'url:python': 0.32; '(2)': 0.32; 'url:listinfo': 0.32; "aren't": 0.33; 'instances': 0.33; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; '(1)': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'tool': 0.36; 'url:org': 0.36; 'method': 0.36; 'subject: (': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'url:mail': 0.40; 'your': 0.60; '&amp;': 0.61; 'skip:n 10': 0.63; 'state.': 0.71; '2013': 0.84; 'etc,': 0.84; 'self.value': 0.84; 'subject:read': 0.84; 'subject:write': 0.84; 'fibonacci': 0.91; 'write:': 0.91
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=8Ba2NADrLDKeYgbNkTGODCRnjhK9D1GPcxW2zKSiOH4=; b=OSHql22lU89A0aFeHtJ1Ki4I9Km9MVBqunyngJtSdK8vIaAdp9UeRz7Rv5Vu3rTu0h TwvRN1emQJHol/w2pVtCKC/X8pdnCMQtLQAAJ5Tn8x4FtGHo359jY1cvoSuMXIP17bhV iqLMkOAHdoJP8em6p4HznWausau24w9NWOqEMN2S/tpK15RDnizRUy9sOOmUHUkZzFQm Q7T1uXcBArk18AWhTiTIAGHCgz1VmpPyr+2+lS3IjM2EMUnZdGKny5O0tF8rQRANZP2u lOia540H8ygK5405I7vemGqi3/QzaHHjBk04G0fArOoADZNQsE8Oz1Yxz5qXmubVc8bv sKig==
MIME-Version 1.0
In-Reply-To <CAPTjJmrP4s=wba1jmfRuYiR7LeHUTiOztE_-21ibCBzzx36HgQ@mail.gmail.com>
References <46c8a630-de27-41dc-8b8b-1951ba747447@googlegroups.com> <CAPTjJmrP4s=wba1jmfRuYiR7LeHUTiOztE_-21ibCBzzx36HgQ@mail.gmail.com>
From Chris Kaynor <ckaynor@zindagigames.com>
Date Mon, 14 Jan 2013 13:37:33 -0800
Subject Re: Finding the variables (read or write)
To "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=20cf300fb0fd23d15b04d34675a1
X-Gm-Message-State ALoCoQloP/4EVsj8010+Y6kZvHFGMiflagG1oT8yKjbjIme0TrVhNc1jYrfRK5+hU8K6NWomnOET
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.521.1358199482.2939.python-list@python.org> (permalink)
Lines 124
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358199482 news.xs4all.nl 6923 [2001:888:2000:d::a6]:54678
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36822

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Mon, Jan 14, 2013 at 1:28 PM, Chris Angelico <rosuav@gmail.com> wrote:

> 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)?
>

And those aren't even covering the case that a, normally non-mutating,
method actually mutates. Consider the following class (untested):

class Test(object):
  def __init__(self, value):
    self.value = value
    self.adds = 0
  def __add__(self, other):
    self.adds += 1
    other.adds += 1
    return Test(self.value + other.value)

With that class,
 x = a + b
would mutate x, a, and b, presuming a and b are instances of Test.


>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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