Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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:error': 0.03; 'attribute': 0.07; 'error:': 0.07; 'instance.': 0.09; 'lookup': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; 'attribute,': 0.16; 'evaluates': 0.16; 'marco': 0.16; 'normally,': 0.16; 'object)': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'repl': 0.16; 'situation.': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'meant': 0.20; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'said,': 0.30; 'statement': 0.30; 'code': 0.31; "skip:' 10": 0.31; '(unless': 0.31; 'class': 0.32; 'classes': 0.35; 'but': 0.35; 'accessible': 0.36; 'instances': 0.36; 'words,': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'different': 0.65; 'received:fios.verizon.net': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: __bases__ misleading error message Date: Sat, 24 Jan 2015 19:55:18 -0500 References: <1a194e0a0b738d205de54180fa7@nntp.aioe.org> <54C413E4.5060208@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-108-16-203-145.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <54C413E4.5060208@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422147330 news.xs4all.nl 2924 [2001:888:2000:d::a6]:57286 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84533 On 1/24/2015 4:51 PM, Marco Buttu wrote: > On 24/01/2015 20:24, Terry Reedy wrote: > >> On 1/24/2015 5:16 AM, Mario Figueiredo wrote: >>> >>> Consider the following code at your REPL of choice >> >>> class Sub: >>> pass >>> >>> foo = Sub() >>> >>> Sub.__bases__ >>> foo.__bases__ >>> >>> The last statement originates the following error: >> >> This is an anomalous situation. 'This situation' being that Someclass.attro works but Someclass().attro raises. Normally, if a class has an attribute, In other words, if 'Someclass.attro' evaluates to an object >> instances have the same attribute then 'Someclass().attro' *normally* evaluates to the same object >> (unless overriden). (unless 'Someclass().attro' has been bound to a different object) because attribute lookup on an instance reverts to attribute lookup on the class and even its super classes (__bases__). Someclass.__bases__ is special; it is not listed by dir(Someclass), and it is not accessible via an instance. > That is not true: What I said, as I meant it to be understood, is true. -- Terry Jan Reedy