pydoc in 2.1: Missing static methods
fgeiger at datec.at
Mon Oct 8 20:57:54 CEST 2001
I use pydoc of ActivePython 2.1.212 and am pretty happy with it, except when
it comes to "static methods": Such methods are not shown by pydoc!
I use Alex Martelli's pattern to define the static methods (aka
class-methods, see AS' Python Cookbook):
def restoreFromSession(name, session, request):
form = pickle.loads(session.value(name))
form._request = request
restoreFromSession = static(restoreFromSession)
I guess pydoc misses "self", which is definitely not there, and therefore
does not recognize restoreFromSession as a method belonging to HcForm. OTOH
I don't know how pydoc should label this method. Should it prefix it with
"static"? Or should it simply list it with the other methods?
static() is defined like so:
'Static-methods' (aka 'class-methods') in Python. Copied from Alex
contribution in the ActiveState Python Cookbook.
myStaticMethod = static(myStaticMethod)
def __init__(self, anyCallable):
self.__theCallable = anyCallable
def __call__(self, *args, **kwds):
return self.__theCallable(*args, **kwds)
More information about the Python-list