Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.05; 'case.': 0.05; 'class,': 0.07; 'python': 0.09; 'descriptor': 0.09; 'exist.': 0.09; 'exists,': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'result.': 0.15; 'attributes:': 0.16; 'attrname': 0.16; 'bases,': 0.16; 'descriptor,': 0.16; 'non-data': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'received:gateway13.websitewelcome.com': 0.16; 'retrieving': 0.16; 'exists': 0.17; "shouldn't": 0.17; 'url:article': 0.17; 'subject:skip:i 10': 0.22; 'raise': 0.24; 'header:User-Agent:1': 0.26; '[1]': 0.27; 'question': 0.27; '[2]': 0.27; 'found.': 0.27; "doesn't": 0.28; 'steps:': 0.29; 'points': 0.29; 'class': 0.29; "i'm": 0.29; 'returned': 0.30; 'point': 0.31; 'anybody': 0.32; 'to:addr:python-list': 0.33; 'wrong': 0.34; 'sequence': 0.35; 'too.': 0.35; 'there': 0.35; '(i.e.': 0.36; 'does': 0.37; 'data': 0.37; 'object': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'step': 0.39; 'header:Received:5': 0.40; 'here': 0.65; 'received:69.56': 0.65; 'special': 0.73; '(print': 0.84; 'to:name:python': 0.84 Date: Fri, 05 Oct 2012 10:39:53 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Python Subject: instance.attribute lookup Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.10.136]) [72.11.125.166]:3014 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349459170 news.xs4all.nl 6955 [2001:888:2000:d::a6]:59720 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30827 There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectname.attrname) Python follows these steps: > > 1. If attrname is a special (i.e. Python-provided) attribute for > objectname, return it. > > 2. Check objectname.__class__.__dict__ for attrname. If it exists and > is a data-descriptor, return the descriptor result. Search all bases > of objectname.__class__ for the same case. > > 3. Check objectname.__dict__ for attrname, and return if found. If > objectname is a class, search its bases too. If it is a class and a > descriptor exists in it or its bases, return the descriptor result. > > 4. Check objectname.__class__.__dict__ for attrname. If it exists and > is a non-data descriptor, return the descriptor result. If it exists, > and is not a descriptor, just return it. If it exists and is a data > descriptor, we shouldn't be here because we would have returned at > point 2. Search all bases of objectname.__class__ for same case. > > 5. Raise AttributeError I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody know otherwise? ~Ethan~ [1] http://stackoverflow.com/q/10536539/208880 [2] http://www.cafepy.com/article/python_attributes_and_methods/ch01s05.html