Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news-transit.tcx.org.uk!rt.uk.eu.org!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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'beginners': 0.04; 'python': 0.08; 'descriptor': 0.09; 'protocol': 0.15; 'enlighten': 0.16; 'functools': 0.16; 'obj,': 0.16; 'pydoc': 0.16; 'cc:addr :python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.20; 'programming': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'import': 0.27; 'message- id:@mail.gmail.com': 0.28; 'partial': 0.29; 'cc:addr:python.org': 0.29; "i've": 0.31; 'me?': 0.32; 'someone': 0.34; 'something': 0.35; 'url:python': 0.36; 'received:209.85.161': 0.36; 'but': 0.37; 'reference': 0.37; 'received:google.com': 0.37; 'skip:_ 10': 0.37; 'using': 0.38; 'received:209.85': 0.38; 'received:209': 0.40; '2011': 0.61; 'url:htm': 0.72; 'amaze': 0.84; 'fantastic,': 0.84; 'look.': 0.93; 'absolutely': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=mTC2aVuMatsWAbknK0f6NfiuCiBgSw/mNRJImiIC90Q=; b=XHx/6yApjzUU3jns5LL84kJImoSB6HfVITxpoT6YdkanZ4bsAkGSCV/D6Zyw6FgM8z sCbeC1I5ufS0muvAGv/1yjN6951qh3jAnLmIRKCsknZ4UUaConOTsImVzGpYjhbonNo6 m0+GFMZWtTDFAqUJwAbIXnciu9/W9Mt2aDH2k= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 12 Dec 2011 14:01:31 +0000 Subject: Re: Confusion about decorators From: Arnaud Delobelle To: Henrik Faber Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323698494 news.xs4all.nl 6982 [2001:888:2000:d::a6]:38440 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17043 On 12 December 2011 13:52, Henrik Faber wrote: > On 12.12.2011 14:45, Arnaud Delobelle wrote: > >>> Can someone please enlighten me? >> >> You can (need to?) use the descriptor protocol to deal with methods. >> >> from functools import partial > [...] >> =C2=A0 =C2=A0 =C2=A0 =C2=A0def __get__(self, obj, objtype): >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return partial(se= lf, obj) > > Whoa. This is absolutely fantastic, it now works as expected (I get a > reference to "self"). > > I am very amazed -- I've been programming Python for about 5 years now > and have never even come close to something as a "descriptor protocol". > Python never ceases to amaze me. Do you have any beginners guide how > this works? The Pydoc ("Data Model") is comprehensive, but I really > don't know where to start to look. Well, I've been using Python for 10 years :) The best reference I know is: http://users.rcn.com/python/download/Descriptor.htm --=20 Arnaud