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


Groups > comp.lang.python > #41875

Re: At a loss on python scoping.

Path csiph.com!usenet.pasdenom.info!goblin1!goblin.stu.neva.ru!news.astraweb.com!border5.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <i@introo.me>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '&quot;the': 0.07; 'memory.': 0.07; 'falls': 0.09; 'received:209.85.219': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'question.': 0.14; 'a()': 0.16; 'empty.': 0.16; 'gpg': 0.16; 'subject:loss': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'obscure': 0.31; 'class': 0.32; 'url:python': 0.33; 'guess': 0.33; '"the': 0.34; 'maybe': 0.34; 'skip:d 20': 0.34; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'example,': 0.37; 'so,': 0.37; 'list': 0.37; 'received:209': 0.37; 'step': 0.37; 'question,': 0.38; 'pm,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'url:about': 0.61; 'first': 0.61; 'name': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'mar': 0.68; '26,': 0.68; 'url:me': 0.69; '2013': 0.98
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=HDp5awAziKokJpLMjFxHVhWQri0Ipg2DSPbU9suN55s=; b=MQHb+kmgDGJ67msjSuIxnhfFiZoVrRAlNKqWEItJb98dKgywiru2LXlHfKwriuIOeR NRonJcXZuYthWyWwqWXsRZ5KHovrXHOLG0BBDz9FHya3BzSwwXbJgJn9TjpEpzi6OW9K 2dt4M1niC5LRaPsgvpDw8OfuTWGlm2ioAY1oVMm/NTzZuNiP8Jt9sVShGe9vlqQAK4PF QWx4rC+SCFQx2vUJkK4X78r0gfYEVfWj1FAlZpdU/HaD7Hr7+oG7mzZCaCmSKBDZu7lg RjAu/3ULXNt0zSycRKUyHLMmJpVMDob0nPVzvzwwxy88l9iu3dO9qnEAgr1HOZY8zntL VNAw==
MIME-Version 1.0
X-Received by 10.182.241.134 with SMTP id wi6mr1893951obc.46.1364294129112; Tue, 26 Mar 2013 03:35:29 -0700 (PDT)
X-Originating-IP [59.66.130.213]
In-Reply-To <CAPTjJmoeW9sZ-PCNkJzXr7PCZKEgDvZrdE_URz_RBExDDAH5vA@mail.gmail.com>
References <CAJQX3DyT53ocRcxW+1+xRWON2wzoAwEEkEO-zFTXBRm_v5KCOQ@mail.gmail.com> <CAPTjJmoeW9sZ-PCNkJzXr7PCZKEgDvZrdE_URz_RBExDDAH5vA@mail.gmail.com>
Date Tue, 26 Mar 2013 18:35:28 +0800
Subject Re: At a loss on python scoping.
From Shiyao Ma <i@introo.me>
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=001a11c2b0eaef703904d8d17a45
X-Gm-Message-State ALoCoQlluK5Owo4j9zlX0kitsOSzRcw0Cds2gmCh7HpoVmt3aNRun0/QIO6cECEAZIVnTtw7nHNH
Cc python-list@python.org
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.3730.1364294131.2939.python-list@python.org> (permalink)
Lines 86
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364294131 news.xs4all.nl 6963 [2001:888:2000:d::a6]:50234
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41875

Show key headers only | View raw


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

Sorry for my obscure description.
"the name of r" , AFAIK, everything in python is just a reference. For
example, a = 3, means a points to a small integer; b= [] means b points to
a list somewhere in the memory. So I call r as the name of r.

To clarify my question.
say I wanna look up a.r
I guess the first step is to look inside a, maybe in the __dict__?
As proved in my ipython, the __dict__ is empty.
So, it will look up in A.__dict__
Here comes my first question, where does the scope of class A falls in when
considering LEGB.

On Tue, Mar 26, 2013 at 2:29 PM, Chris Angelico <rosuav@gmail.com> wrote:

> On Tue, Mar 26, 2013 at 5:17 PM, Shiyao Ma <i@introo.me> wrote:
> > class A:
> >     r = 5
> >     def func(self, s):
> >         self.s = s
> > a = A()
> > print(a.r)    # this should print 5, but where does py store the name of
> r
>
> What do you mean by "the name of r"?
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
My gpg pubring is available via: gpg --keyserver
subkeys.pgp.net--recv-keys 307CF736

More on: http://about.me/introom

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


Thread

Re: At a loss on python scoping. Shiyao Ma <i@introo.me> - 2013-03-26 18:35 +0800

csiph-web