Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.045 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'stack,': 0.09; 'stack.': 0.09; 'subject:Function': 0.09; 'python': 0.11; 'globals': 0.16; 'globals(),': 0.16; 'globals.': 0.16; 'indirectly': 0.16; 'all.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'example': 0.22; 'affects': 0.24; 'module,': 0.24; 'mon,': 0.24; 'push': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'resolution': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'though.': 0.31; 'figure': 0.32; 'quite': 0.32; 'could': 0.34; 'subject: (': 0.35; "can't": 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'to:addr:python- list': 0.38; 'that,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'called': 0.40; 'even': 0.60; 'ian': 0.60; 'matter': 0.61; 'simply': 0.61; 'name': 0.63; 'become': 0.64; 'more': 0.64; 'different': 0.65; 'fact,': 0.69; 'difference.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=vXrVvuHjNpDN6kWAWFOCvbE2wzchW9Ff5l50R+aOaXo=; b=n6NHSNJbZoIPME6713v4PKZFqXotTMud2TymQOSMXROx23bhtQkr1vXPeuFuVCB4Kn 6mgzf9afa+aZQ9Fz+GtrFk5ZxcckMVFWqCarnjC8ieKhHwTXpcz7o1xtGY0LyGJg2jUY axiwnrT5edR1rbbwGjxNtqkkXIkm+EBRV/3OWCv74Z9KoQpnD4BhkgzKlXg8dur9GwBc 2S9lqDkDSiIlm5xnCffol1Zh2iNR49BdODsG3jL2jJFB1MQRMIqTwvrubsyVCe1m4/LL IAYAs9t+1tbGMig6RLXmzOEJJ3NndzEj8s7OknvA9Tr7neFUbbUlP8AH12mzndEGnB1n sYHQ== X-Received: by 10.236.227.230 with SMTP id d96mr3195748yhq.100.1402248308634; Sun, 08 Jun 2014 10:25:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <8b96ae27-20fa-4df9-807e-c806fed983c0@googlegroups.com> <1dd863ba-09e5-439b-8669-db65f3e999eb@googlegroups.com> <927afb61-be0e-43a1-8aab-107e77a013fc@googlegroups.com> From: Ian Kelly Date: Sun, 8 Jun 2014 11:24:28 -0600 Subject: Re: Uniform Function Call Syntax (UFCS) To: Python Content-Type: text/plain; charset=UTF-8 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402249956 news.xs4all.nl 2967 [2001:888:2000:d::a6]:37376 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72982 On Sun, Jun 8, 2014 at 11:13 AM, Chris Angelico wrote: > On Mon, Jun 9, 2014 at 3:08 AM, Ian Kelly wrote: >> On Sun, Jun 8, 2014 at 10:48 AM, Chris Angelico wrote: >>> Except that it's even more complicated than that, because hasattr >>> wasn't defined in your module, so it has a different set of globals. >>> In fact, this would mean that hasattr would become quite useless. >> >> hasattr is a builtin, so it has no globals at all. It would have to >> use the calling scope for UFCS resolution as in my example >> implementation. > > Same difference. It can't simply look for the name in globals(), it > has to figure out based on the caller's globals. But that would all be done in getattr, so I don't think it affects hasattr's implementation at all. Since hasattr doesn't push anything onto the stack, getattr doesn't have to care whether it was called directly from Python or indirectly via getattr; either way the scope it needs is just the top frame of the stack. Could be a different matter in other implementations, though.