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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.08; 'assert': 0.09; 'foo': 0.09; 'subject:method': 0.09; 'subject:reference': 0.09; '16,': 0.15; "subject:' ": 0.15; 'luna': 0.16; 'py3k': 0.16; 'subject: \n ': 0.16; 'subject:which': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.26; "i'm": 0.28; 'message-id:@mail.gmail.com': 0.29; 'class': 0.29; 'example': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'but...': 0.30; 'porting': 0.30; 'chris': 0.30; 'subject:?': 0.31; 'does': 0.32; 'fri,': 0.34; 'subject:How': 0.35; 'received:209.85.214': 0.36; 'reference': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'could': 0.38; 'received:209': 0.39; 'sender:addr:chris': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=uwS7A8fk5L3OnRJ5eZHhuL4z/ZvWeMrBmlGONQlm6/g=; b=UerO6Bv1hFUIXSYBf0SZpO6KNYTrVsZ4thS2iaK7WphXuw2aykM63caa08Ryp/2BB7 0W+ZA85wBRsxJA6Vvl+yUMm1P2W/dsMc89t/LQ/DnfQqDlSpl8E2EVdkUWllIgE3YvHs Kl541YU3QsvaDZdouMu6LqO27b8a5egNY9te0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=uwS7A8fk5L3OnRJ5eZHhuL4z/ZvWeMrBmlGONQlm6/g=; b=Tpw/hQxr01pxQiabw7MnhNbsXIWgNjAydHmaRCxnSAPfNOxnUcKh9cK1WlJTP+xGi/ WrMhEskYwUaRIdOIST3Q55Cy2zWp9BMMyCUMf+ZrzoYUVQrtyhjitGuv7mJqYFN71Tjy DeJJ5lAQ9ZBZUAj3btBwPNE5Sg9ktsTIVYCxGVAnrOwJY1chhUzAbH7mop0kFocASuyi fjmE7R6uUjI8NMMR26Qrd2xq+4CVkL/PPqlggY7yLJ6D4hLYBq1yyr9hRMxMFx6OUCz8 gBc1Q4L4H8h92AeCb9GpreFVpaf19pUNqwa+ykI0a0CQxnTOni85nHNXQRf3Trls8Y7I C6Jg== MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <20411334.2044.1331962234309.JavaMail.geo-discussion-forums@yncd8> References: <20411334.2044.1331962234309.JavaMail.geo-discussion-forums@yncd8> Date: Fri, 16 Mar 2012 22:51:05 -0700 X-Google-Sender-Auth: eHCiUk1l3Sa8HR4ep4Ok34Y8mDM Subject: Re: How to get a reference of the 'owner' class to which a method belongs in Python 3.X? From: Chris Rebert To: Cosmia Luna Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkEExPp+Ge862mMLAVU+KFvkOoMBwzQKAZwqDmPaC3H5avxByyfnMOy0v2WQ1dOJb+XLggu 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331963468 news.xs4all.nl 6903 [2001:888:2000:d::a6]:39002 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21802 On Fri, Mar 16, 2012 at 10:30 PM, Cosmia Luna wrote: > I'm porting my existing work to Python 3.X, but... > > class Foo: > =C2=A0 =C2=A0def bar(self): > =C2=A0 =C2=A0 =C2=A0 =C2=A0pass > > mthd =3D Foo.bar > > assert mthd.im_class is Foo # this does not work in py3k > > So, how can I get a reference to Foo? This is important when writing > decorators, Could you give an example of such a decorator? Cheers, Chris