Class decorator with argument
mrkafk at gmail.com
Fri Jan 16 21:15:58 CET 2009
I wrote this class decorator with argument:
>>> class ChangeDoc(object):
def __init__(self, docstring):
self.docstring = docstring
def __call__(self, func):
func.__doc__ = self.docstring
It seems to work:
Can someone please debug my reasoning if it's incorrect?
1. First, the decorator @ChangeDoc('bulba') instantiates with
__init__(self, 'bulba'), to some class instance, let's call it _decor.
2. Then _decor's __call__ method is called with function f as argument,
changing the docstring and returning the changed f object, like f =
Am I missing smth important / potentially useful in typical real-world
applications in that picture?
More information about the Python-list