How would I write this introspective function without using the inspect module.
for name, m in inspect.getmembers(cls, inspect.ismethod):
something like this:
>>> class Tester(object): ... def mymethod(self): ... return True ... >>> hasattr(Tester, 'mymethod') True >>> hasattr(Tester.mymethod, 'im_func') True
from the python docs on the data model scroll down a bit to get to "user defined methods".
Special read-only attributes: im_self is the class instance object, im_func is the function object; im_class is the class of im_self for bound methods or the class that asked for the method for unbound methods; __doc__ is the method’s documentation (same as im_func.__doc__); __name__ is the method name (same as im_func.__name__); __module__ is the name of the module the method was defined in, or None if unavailable.
im_func and im_self as of 2.6 are also availabale as
I sort of tend to gravitate here than use the inspect module myself.