Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17042

Re: Confusion about decorators

From Henrik Faber <hfaber@invalid.net>
Newsgroups comp.lang.python
Subject Re: Confusion about decorators
Date 2011-12-12 14:52 +0100
Organization Aioe.org NNTP Server
Message-ID <jc50ui$c84$1@speranza.aioe.org> (permalink)
References <jc4vg9$8eo$1@speranza.aioe.org> <mailman.3544.1323697523.27778.python-list@python.org>

Show all headers | View raw


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
[...]
>        def __get__(self, obj, objtype):
>                return partial(self, 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.

Still amazed!

Best regards,
Henrik

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Confusion about decorators Henrik Faber <hfaber@invalid.net> - 2011-12-12 14:27 +0100
  Re: Confusion about decorators Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-12 13:37 +0000
    Re: Confusion about decorators Henrik Faber <hfaber@invalid.net> - 2011-12-12 14:45 +0100
  Re: Confusion about decorators Arnaud Delobelle <arnodel@gmail.com> - 2011-12-12 13:45 +0000
    Re: Confusion about decorators Henrik Faber <hfaber@invalid.net> - 2011-12-12 14:52 +0100
      Re: Confusion about decorators Arnaud Delobelle <arnodel@gmail.com> - 2011-12-12 14:01 +0000
        Re: Confusion about decorators Henrik Faber <hfaber@invalid.net> - 2011-12-12 16:35 +0100

csiph-web