Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.09; 'notation': 0.09; 'looked': 0.10; 'def': 0.10; 'aug': 0.13; 'slightly': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'subject:Objects': 0.16; 'unambiguous': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'import': 0.21; 'received:209.85.214.174': 0.21; 'explicit': 0.22; 'header:In-Reply-To:1': 0.25; 'compiled': 0.27; 'message-id:@mail.gmail.com': 0.27; 'there.': 0.28; 'run': 0.28; "d'aprano": 0.29; 'staying': 0.29; 'steven': 0.29; 'gets': 0.32; "he's": 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'between': 0.63; 'different': 0.63; 'road': 0.63; '26,': 0.65; 'talking': 0.66; 'smith': 0.71; 'about,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=r7XlYxMNhqvon5UfMEPJGmTiDTsz0MQhh0Q2e1LgNKc=; b=zAAOjrjFywN+jr0lLaqwFIxHIF8zymOTyS5AV6ESD2tELGEet7vry0QgSuUjjXB4gQ Rg7qt9tF9RCoiiDZjBdifhQa12S3U8oejIzRdnI15KzM9/WLHKYilU7ZnA8kuhJYH/U2 tJ+76I9QR/KvEXUubPEcIQnrDkrqUAVdASKts/hZvdO1f0JB4p+yDMMo72T9KH5M1Qj2 WHimnLULo0Q2nW6D7Bd1tUkMK2JrEK18aeQdQLV15/CvRfuNI/brHbb/GPturqunk+bq xRddqSgaqx7XE6iO0zkTD3tcQyb0mJtoCuPbmJQqrEfQ1ho6D4xHkAV1ppVu16ZUsUbR +zWg== MIME-Version: 1.0 In-Reply-To: <503a2804$0$6574$c3e8da3$5496439d@news.astraweb.com> References: <18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com> <87d32i1ntc.fsf@benfinney.id.au> <7df4c317-7ad8-4158-900a-b52f19c3caf2@k9g2000pbr.googlegroups.com> <503750b9$0$6574$c3e8da3$5496439d@news.astraweb.com> <503a2804$0$6574$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 26 Aug 2012 23:58:31 +1000 Subject: Re: Objects in Python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345989515 news.xs4all.nl 6934 [2001:888:2000:d::a6]:51954 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27922 On Sun, Aug 26, 2012 at 11:43 PM, Steven D'Aprano wrote: > It gets worse: Python has multiple namespaces that are searched. > > "Go to the Excelsior Hotel and ask the concierge for Mr Smith. If Mr > Smith isn't staying there, go across the road to the Windsor Hotel and > ask there. If he's not there, try the Waldorf Astoria, and if he's not > there, try the Hyperion." Does it? I thought the difference between function-scope and module-scope was compiled in, and everything else boils down to one of those. Explicit dot notation is different ("ask for Mr Smith, then ask him where his packages box is, and put this in the box"). Hmm, okay, there's something slightly different with closures. But it's still unambiguous at compile time. >>> x=1 >>> def foo(y): return lambda z: x+y+z >>> foo(2)(3) 6 >>> import dis >>> dis.dis(foo(2)) 2 0 LOAD_GLOBAL 0 (x) 3 LOAD_DEREF 0 (y) 6 BINARY_ADD 7 LOAD_FAST 0 (z) 10 BINARY_ADD 11 RETURN_VALUE What multiple namespaces are you talking about, where things have to get looked up at run time? ChrisA