Override a method but inherit the docstring
steve at REMOVE-THIS-cybersource.com.au
Fri Jul 17 09:52:19 CEST 2009
On Fri, 17 Jul 2009 12:58:48 +1000, Ben Finney wrote:
>> Using a decorator in this manner requires repeating the super class
>> name. Perhaps there is a way to get the bases of BarGonk, but I don't
>> think so, because at the time that the decorator is called, BarGonk is
>> not yet fully defined.
> Yes, I tried a few different ways, but within the decorator it seems the
> function object is quite unaware of what class it is destined for.
When the decorator is called, the function object is just a function
object, not a method, so there is no concept of "what class it is
>>> def dec(func):
... print type(func)
... print func.im_class
... print "no im_class"
... return func
>>> class Test(object):
... def spam(self):
I suppose you could try to determine what namespace you're currently when
the class is created, but that's surely going to be fragile and messy.
More information about the Python-list