Decorating class member functions

Jorge Godoy jgodoy at gmail.com
Thu May 3 22:38:19 EDT 2007


Andy Terrel <andy.terrel at gmail.com> writes:

> I just need to keep the state around. I make a call to some function
> that is pretty expensive so I want to save it as a member during the
> __init__ of the decorator.
>
> Yeah I'm afraid it can't be done either, that's why I asked the group.

Have you looked at memoize decorators?  They seem to do what you want.
There are examples at the Python website (some link in there, I'm
sorry...).

This will give you lots of resources, including full recipes and
comments from the Python cookbook:
http://www.google.com.br/search?q=python+decorator+memoize


-- 
Jorge Godoy      <jgodoy at gmail.com>



More information about the Python-list mailing list