I’ve got a class that I’m adding a help-function to with setattr. The function is a properly created instancemethod and works like a charm.
import new
def add_helpfunc(obj):
def helpfunc(self):
"""Nice readable docstring"""
#code
setattr(obj, "helpfunc",
new.instancemethod(helpfunc, obj, type(obj)))
However, when calling help on the object instance, the new method is not listed as a member of the object. I thought help (i.e. pydoc) used dir(), but dir() works and not help().
What do I have to do to get the help information updated?
I there a specific reason you do it the complicate way? Why not just doing it like this:
Adding the method this way also fixes your help-problem if I am not wrong…
Example: