Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'override': 0.07; 'received:mail-lpp01m010-f46.google.com': 0.09; 'subject:method': 0.09; 'subject:reference': 0.09; 'am,': 0.12; "subject:' ": 0.15; '__init__': 0.16; 'bound.': 0.16; 'luna': 0.16; 'subject: \n ': 0.16; 'subject:which': 0.16; 'unbound': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'itself,': 0.23; 'do,': 0.25; 'cc:2**0': 0.26; "i'm": 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'sun,': 0.30; 'subject:?': 0.31; 'actually': 0.31; 'received:209.85.215.46': 0.32; 'does': 0.32; 'all.': 0.34; 'calling': 0.34; 'anything': 0.34; 'copied': 0.34; 'copying': 0.35; 'subject:How': 0.35; 'bound': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'should': 0.38; 'received:209.85.215': 0.39; 'received:209': 0.39; 'your': 0.61; 'dict,': 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 :cc:content-type; bh=jX/jqr1HY2B5grioW16XW2kcRs1xlD9z4y892vrV084=; b=YPpq3V9Aw9DTCW5ZsRb9ooRwG4hwtOCISLr+g5OekYmM7CuxfioTdI+aHvPnExNHzW 39DcRv5vJr9yaxcr0mM3pzpGwn0bwnrfJS+F1Rte9OdzenXYJvLOqcK2smxxtK0KBjFd 19VFznm4eDBlQYWpkZbGR60VuMH8dZppebjoE+B7S8KTpLM1bBFnO3r1DAFblrY+nWsD J3qhNvlkK00v8SsQKghb6AK3Uzx2q/BqGbh4V5iadqS6u4+jZJRtPax9zXuDJmfLPRPu k+lR0eR5Ho1YVOAE2tijzx4pEvCY/hmG9HZ1VTR/2x61vuTqBiIK7UrpmYtzQh2hBXS3 vFCw== MIME-Version: 1.0 In-Reply-To: <14929632.47.1332063740635.JavaMail.geo-discussion-forums@ynbq18> References: <20411334.2044.1331962234309.JavaMail.geo-discussion-forums@yncd8> <14929632.47.1332063740635.JavaMail.geo-discussion-forums@ynbq18> From: Ian Kelly Date: Sun, 18 Mar 2012 10:14:12 -0600 Subject: Re: How to get a reference of the 'owner' class to which a method belongs in Python 3.X? To: Cosmia Luna Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332087285 news.xs4all.nl 6969 [2001:888:2000:d::a6]:52639 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21860 On Sun, Mar 18, 2012 at 3:42 AM, Cosmia Luna wrote: > But it seems that the last line(#ref2) in the Py2Type.__init__ does not work at > all. I'm not sure what you're expecting it to do, but type.__init__ does not actually do anything > It seems really weird, 'type' is an instance of 'type' itself, I'm not sure > if I'm calling the unbound method __init__ or bound method __init__. type.__init__ is never bound. > It seems type.__new__ calls type.__init__ before it calls Py2Type.__init__, > because dict_ is already copied to cls.__dict__ at line(#ref3). No, type.__new__ does not call type.__init__ at all. Rather, it is type.__new__ that is responsible for copying the dict, not type.__init__. For this reason you should override type.__new__ in your metaclass, not type.__init__. Cheers, Ian