pydoc in 2.1: Missing static methods

F. GEIGER fgeiger at datec.at
Mon Oct 8 20:57:54 CEST 2001


Dear Pythoneers,

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):

class HcForm:

<snipped>

   def restoreFromSession(name, session, request):
      try:
         form = pickle.loads(session.value(name))
      except KeyError:
         return None
      form._request = request
      form.__processRequest()
      return form

   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:

class static:
   """
   SYNOPSIS:
      'Static-methods' (aka 'class-methods') in Python. Copied from Alex
Martelli's
      contribution in the ActiveState Python Cookbook.

   SAMPLE:
      class MyClass:
         def __init__(self):
            pass

         def myStaticMethod(self):
            pass

         myStaticMethod = static(myStaticMethod)

      def test():
         MyClass.myStaticMethod()

      test()
   """
   def __init__(self, anyCallable):
      self.__theCallable = anyCallable

   def __call__(self, *args, **kwds):
      return self.__theCallable(*args, **kwds)


Any ideas?

Best regards
Franz







More information about the Python-list mailing list