Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attributes': 0.05; 'attribute': 0.07; 'something,': 0.07; 'difference,': 0.09; 'subclasses': 0.09; 'api': 0.09; 'am,': 0.12; 'attribute,': 0.16; 'cc:addr:benfinney.id.au': 0.16; 'cc:name:ben finney': 0.16; 'guilty': 0.16; 'subject:Overriding': 0.16; 'subject:global': 0.16; 'cc:addr:python-list': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'meant': 0.17; 'wrote:': 0.18; 'functions,': 0.18; 'cc:no real name:2**0': 0.20; "aren't": 0.21; 'dec': 0.22; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'replacing': 0.23; 'code': 0.25; 'saying': 0.26; 'code.': 0.26; "i'm": 0.26; 'code,': 0.27; 'specifically': 0.27; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'class': 0.29; 'kelly': 0.30; 'does': 0.32; 'tue,': 0.32; 'there': 0.33; 'anything': 0.34; 'received:74.125.82': 0.35; 'external': 0.35; 'uses': 0.36; 'cc:2**1': 0.36; 'class.': 0.37; 'variables': 0.37; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'accepted': 0.38; 'either': 0.39; 'should': 0.39; 'extend': 0.39; '2011': 0.61; 'order': 0.62; 'due': 0.66; 'claim': 0.76; 'hand,': 0.76; 'expectations': 0.77; '12:43': 0.84; 'no?': 0.84; 'confusion.': 0.91; 'presumably': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=7Zp6Tif26zVJgv/wxco5cJ/tcHWL0a+vus2aVOv1KUw=; b=uUfzRGosr7U+72fqrnEWAhJWACwufE3XUbJ7Z8iiPGO0wTdD1Zd+EadG++80EA7ZxV 0RwgPs17j0hrcmsCDqWr93Z6GveLlyk0a7vI/rfTT/EG+y5cej3JU+C2t/TOyy4oMK4c BiqDJlOyNs1N04Mz+rY9j3IllYtfjbdHGeEuw= MIME-Version: 1.0 In-Reply-To: References: <4ee671f6$0$29979$c3e8da3$5496439d@news.astraweb.com> <87k4611l4y.fsf@benfinney.id.au> From: Ian Kelly Date: Tue, 13 Dec 2011 12:54:09 -0700 Subject: Re: Overriding a global To: Joshua Landau Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org, Ben Finney 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323806080 news.xs4all.nl 6979 [2001:888:2000:d::a6]:56662 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17168 On Tue, Dec 13, 2011 at 12:43 PM, Joshua Landau wrote: > On 13 December 2011 19:34, Ian Kelly wrote: >> >> On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau >> wrote: >> >> No, there is another difference, the reason for rebinding the name. >> >> In a subclass, you would rebind a class attribute because that >> >> particular attribute, which you need to change, is used and expected >> >> by external code, either in the base class or in code that uses its >> >> API (or both). =A0Local variables in functions, on the other hand, ar= e >> >> not externally visible, so there is no need to do this in order to >> >> conform to the expectations of external code. =A0All it does in that >> >> case is to sow potential confusion. >> >> >> > So you're saying you should never extend methods or attributes that >> > aren't meant to be used as part of of the API? Because I can claim >> > guilty on this point. >> >> No, I'm only saying that replacing attributes in subclasses is >> accepted because it is necessary due to external dependencies, and >> that local variables in functions don't have that excuse. > > > But they aren't needed due to external dependencies if they're > implementation-specific and not part of the API, no? By "external dependencies" I mean anything that's not specifically part of the subclass. This includes the base class. If they're not part of the API, then the base class presumably uses them for something, and by replacing them, you change the behavior of that base functionality. That's an external dependency.