Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'instance': 0.05; 'python': 0.07; 'attribute': 0.09; 'attribute.': 0.09; 'jones': 0.09; 'referencing': 0.09; 'subclasses': 0.09; '~ethan~': 0.09; '>>>': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'instantiated': 0.16; 'really?': 0.16; 'subject:Classes': 0.16; 'test()': 0.16; '\xa0you': 0.16; 'class,': 0.16; 'tree': 0.20; 'header:In-Reply-To:1': 0.22; 'subject:question': 0.22; 'worked': 0.24; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'pass': 0.27; 'message- id:@mail.gmail.com': 0.28; 'looks': 0.28; 'received:209.85.161': 0.29; 'fri,': 0.29; 'class': 0.29; 'to:addr:python-list': 0.32; 'there': 0.35; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'how': 0.39; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'subject:about': 0.66; 'so:': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=pTMJg46LO/xjccXm4nrxkJHIfn/te0kYKqKHlWVjsss=; b=nELrdq0APN4zd96OorXJ44pbMK7Rg6Pd8ht95kwYO2SidWyVGVTH6UZn4Vcw1S3eVX 3WR1f8WSOdLgurY3/yLhCfbPTmx2+b6QNWale+ULtfEF5jpKjYfkavVlNvSRIk/U8DEd L7pphragUJmoV0Bmfm2BG5P6oHpJ9iXYER3ks= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=B/AHvM1+LJi4/gPBa/q0uRXV5Qv4XRNn9O+Nq0UmXGDmkJDxCYIyYxLaIq6LmS1JeP BeGkVOOWEtuaKvtWute0UAVV5j9kO6v5euHZFF34bNVzpDM2y0ko+HnHYyGp9qI3dpve gc2VXyc6xyc2flVwDbvfL8AOI18zBcsaCWg1A= MIME-Version: 1.0 In-Reply-To: References: <2219ee53-e8aa-4ac4-839f-014c3d1b1914@a19g2000prj.googlegroups.com> From: Ian Kelly Date: Fri, 22 Apr 2011 13:40:59 -0600 Subject: Re: A question about Python Classes To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303501291 news.xs4all.nl 41102 [::ffff:82.94.164.166]:50013 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3888 On Fri, Apr 22, 2011 at 7:49 AM, Kyle T. Jones wrote: >> You don't need to create an instance of BaseHandler. =A0You have the >> class, Python knows you have the class -- Python will look there if the >> subclasses lack an attribute. >> >> ~Ethan~ >> > > Really? =A0That's not at all how I thought it worked in Python > (post-instantiation referencing of class and superclass code...) Yes, it looks up the attribute in the superclass tree at the time that it's referenced, not at the time it's instantiated or at the time the class is created. So: >>> class Base(object): ... x =3D 5 ... >>> class Test(Base): ... pass ... >>> t =3D Test() >>> t.x 5 >>> Test.x =3D 42 >>> t.x 42 >>> Base.x =3D 7 >>> del Test.x >>> t.x 7 Or were you talking about something else?