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


Groups > comp.lang.python > #41854

At a loss on python scoping.

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'suppose': 0.07; 'received:209.85.219': 0.09; 'def': 0.12; 'a()': 0.16; 'example?': 0.16; 'gpg': 0.16; 'subject:loss': 0.16; 'underlying': 0.16; 'subject:python': 0.16; 'print': 0.22; 'this:': 0.26; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'class': 0.32; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'hi,': 0.36; 'should': 0.36; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'url:about': 0.61; 'name': 0.63; 'more': 0.64; 'between': 0.67; 'url:me': 0.69
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:date:message-id:subject :from:to:content-type:x-gm-message-state; bh=dDmzr5yeSzH4Hk18v5OXVyE7/qq2bQSXtPqS04pAnP0=; b=VCwOm5Kxjr8Kq5MLbiVTLxPfcQHvOuEOl1q8FR7EmZLmheDxsvcrzcqnFp6Fi316Gp ColDuSqPVYGCva04+ncsxtmDRXEr5BrqDnDrXaFElrqZGPLqvYeTatL5FkzbOSNxs+JG lMUoeIeIEdXP1wgXL45J5xFNOPVrgPHy0qZo8YsAUqJfM4no3VVXjyFyDLMmGwYdxX6C 6/s9TJ0gtZ5C08+LXqVrEdNR89561A8iKH49brSMro6Ih5uCJ3ICUh+IAOw1XY22Y3HV FDwXw83HK3zIpDp20Rih6BCUTrWfYRIzT0UHEoDrwdSJxRftq+GrBMBlrNKcdN7mQC6c Ny1Q==
MIME-Version 1.0
X-Received by 10.182.118.105 with SMTP id kl9mr1629155obb.52.1364278647152; Mon, 25 Mar 2013 23:17:27 -0700 (PDT)
X-Originating-IP [202.112.3.7]
Date Tue, 26 Mar 2013 14:17:27 +0800
Subject At a loss on python scoping.
From Shiyao Ma <i@introo.me>
To python-list@python.org
Content-Type multipart/alternative; boundary=f46d0447a29f2374c404d8cde0e4
X-Gm-Message-State ALoCoQnOSw+b1agCtMcFEDuz2HcXcl+z2q9L5mWOl2POKrhXY254vzjphBeFAPN4uKtkQO5hrnsJ
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.3716.1364278650.2939.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364278650 news.xs4all.nl 6843 [2001:888:2000:d::a6]:59090
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41854

Show key headers only | View raw


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

Hi,
suppose I have a file like this:
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

a.func(3)
print(a.s)    # this should print 3, also where does py store this name.
what's the underlying difference between the above example?


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

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

csiph-web