Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; '16,': 0.03; '__init__': 0.09; 'function,': 0.09; 'subject:skip:f 10': 0.09; 'cc:addr:python-list': 0.11; '4:25': 0.16; 'called,': 0.16; 'debugger.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'wrote:': 0.18; 'differ': 0.19; 'seems': 0.21; 'appears': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'helpful': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'subject:) ': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'context,': 0.31; 'class': 0.32; 'subject: (': 0.35; "can't": 0.35; 'display': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'nov': 0.38; 'pm,': 0.38; 'rather': 0.38; 'sure': 0.39; 'unable': 0.39; 'called': 0.40; 'name': 0.63; 'provide': 0.64; 'details': 0.65; 'discovered': 0.83; "it'd": 0.84; 'to:none': 0.92 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:cc :content-type:content-transfer-encoding; bh=zeDxs2bMCEEUJiIzaWo1sYllcPHJxaiBusy9ah+4X0s=; b=qOBuzFRg6Me3rZqBeAa5DxiPfBK1x1gilPHbBZWgYN2uuXds3ndqLlxcQPzQBCirr8 CKDisuRKwuVORcaPFPMZmMBqoL9nNEPpn1+aeoRYTkXOk6J4MopnCtUuLW7TX/0Yy3i/ E2meWb4hCIY2EmWXBnHRuBvEIWaiwfGZiOWABU/LeWCqXdtV9yjGeNQAPVwvU7yd5vSH bSHgit/y8+HAbmMfetSfypij+dmKkgJKIdYuDLrnGb1uYgU1kp9HvE9AVWBu9A0Ywiof OMtKZ/cJZSgK2S4GlVVgCLHfc49sy/jkvTImpjJhNlV6EjSwYshB3OjP102/0ePDoOfc iLnw== MIME-Version: 1.0 X-Received: by 10.50.61.140 with SMTP id p12mr12074596igr.34.1416116405868; Sat, 15 Nov 2014 21:40:05 -0800 (PST) In-Reply-To: References: Date: Sun, 16 Nov 2014 16:40:05 +1100 Subject: Re: frame.f_locals['__class__'] -- When does it (not) exist and why? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416116415 news.xs4all.nl 2848 [2001:888:2000:d::a6]:35813 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80856 On Sun, Nov 16, 2014 at 4:25 PM, wrote: > When super().__init__() is called, a 'magic' local appears in frame.f_loc= als called '__class__'. Helpfully, it has the correct class for the contex= t, which will differ from type(self). (I discovered this magic local by po= king around in the debugger. I am unable to find any official documentatio= n on it.) > Interesting. Are you sure you can't get the class name via the function, rather than depending on this magic local? That seems fragile. Your example code isn't currently runnable ("def class"); can you provide a self-contained program that actually attempts to display something? It'd be helpful for those of us who aren't familiar with internal and esoteric details of tracebacks and __init__ :) ChrisA