On 25 oct, 17:18, Joost Molenaar wrote:
> Thanks, Bruno.
> Your python-wiki page and walk-through for the Decorator code make it
> clear. I now finally understand that methods are in fact ordinary
> functions at the time the class is created, and that the descriptor
> protocol turns them into boun
On 25 October 2010 15:20, bruno.desthuilli...@gmail.com
wrote:
> So, your decorator is applied to a function, and wraps it into a
> Decorator object. Or more exactly, the function is defined, then the
> Decorator class is called so a new Decorator object is instanciated
> with the function as argu
On 25 oct, 14:15, Joost Molenaar wrote:
> WebOb contains this little nugget of code that allows you to define a
> decorator that works on both methods and functions:
>
> class Decorator(object):
> def __init__(self, func):
> self.func = func
> def __get__(self, object, type=None):
WebOb contains this little nugget of code that allows you to define a
decorator that works on both methods and functions:
class Decorator(object):
def __init__(self, func):
self.func = func
def __get__(self, object, type=None):
if type is None:
return self