[Doc-SIG] Sort order in pythondoc
Konrad Hinsen
hinsen@cnrs-orleans.fr
Fri, 9 Jul 1999 20:13:01 +0200
> It should be possible if you believe the reference manual,
> where in chapter "3.2 - The standard type hierarchy", where
> you can read under "Internal types" -> "Code objects" (second
> paragraph):
...
Indeed, that works. Here is my code to extract a sort index:
def sort_index(self):
"""Returns a line number from the object's definition in the
source code module, used to have the documentation use the
same order as the source code within one type of object."""
import types
t = type(self.__object)
if t is types.FunctionType:
return self.__object.func_code.co_firstlineno
elif t is types.MethodType or t is types.UnboundMethodType:
return self.__object.im_func.func_code.co_firstlineno
elif t is types.ClassType:
for att in self.__object.__dict__.values():
if type(att) is types.FunctionType:
return att.func_code.co_firstlineno
raise ValueError, "no sort index defined"
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------