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; 'resulting': 0.04; 'cpython': 0.05; 'attribute': 0.07; 'imported': 0.09; 'namespace': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sub': 0.09; 'type,': 0.09; 'python': 0.11; 'jan': 0.12; 'bind': 0.16; 'definition.': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'says...': 0.16; 'language': 0.16; 'wrote:': 0.18; 'module': 0.19; 'value.': 0.19; '>>>': 0.22; 'memory': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; "doesn't": 0.30; 'statement': 0.30; 'object.': 0.31; 'question:': 0.31; 'says': 0.33; 'addresses': 0.33; 'table': 0.34; 'message.': 0.35; 'display': 0.35; 'objects': 0.35; 'but': 0.35; 'add': 0.35; 'thanks': 0.36; 'mapping': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'first': 0.61; 'name': 0.63; 'such': 0.63; 'skip:n 10': 0.64; 'article': 0.77; "'foo'": 0.84; '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 16:58:10 -0500 References: <1a194e0a0b738d205de54180fa7@nntp.aioe.org> <54c39366$0$13006$c3e8da3$5496439d@news.astraweb.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: 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422136703 news.xs4all.nl 2924 [2001:888:2000:d::a6]:37055 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:84500 On 1/24/2015 4:14 PM, Mario Figueiredo wrote: > In article <54c39366$0$13006$c3e8da3$5496439d@news.astraweb.com>, > steve+comp.lang.python@pearwood.info says... >>> AttributeError: 'Sub' instance has no attribute '__bases__', >>> AttributeError: 'foo' object has no attribute '__bases__' >> >> The first would be nice. The second is impossible: objects may have no name, >> one name, or many names, and they do not know what names they are bound to. >> So the Sub instance bound to the name 'foo' doesn't know that its name >> is 'foo', so it cannot display it in the error message. > > Thanks for the information! :) > > But that begs the OT question: How does Python maps names to memory > addresses in the interpreter? Python the language maps names to objects that have identity, type, and value. The CPython implementation does the mapping with a hash table and C pointers (to computer memory addresses), but addresses are not part of the language definition. Neuroscientists still puzzle over how we do such mapping. > "__main__" > from module import a_name A module is a namespace associating names with objects. This statememt says to import the a_name to object association from module and add it to __main__ > y = a_name + 1 This statement uses the imported association in __main__ to access the object and add 1, and bind 'y' to the resulting object. -- Terry Jan Reedy