Overriding all methods in a class
Joao Prado Maia
jpm at papercut.org
Fri Sep 20 16:27:16 CEST 2002
I have been looking for an answer for this question for a while, but
couldn't find anything that would work for what I want to do.
I know that you can use __getattr__ to overload methods that your class
don't have, but what about overloading all methods, so I could in a way
'intercept' calls to my methods and do something different if I wanted, is
that possible ?
What I want to do basically is create a caching system for a specific
class, and have __getattr__ (or any other magic method name) handle the
decision to sue the cached return value or to actually call the method.
Maybe it would be just easier to rename my current class to _Classname and
create a new Classname with just __getattr__.
Any suggestions ?
More information about the Python-list