Sorting attributes by catagory

Nick Vatamaniuc vatamane at gmail.com
Wed May 9 20:11:01 EDT 2007


On May 9, 11:32 am, Ron Adam <r... at ronadam.com> wrote:
> This is for a new version of pydoc if I can get the class attributes sorted
> out.  The module level attributes aren't too difficult to categorize.
>
> (I might be just too tired to see the obvious.)
>
> The original pydoc did this a somewhat round about way, so I would like to
> find a more direct method if possible.
>
> Where dir(obj) is used to get all attributes of a module or class.  And
> they are then sorted into categories depending on what they are.
>
> (In order of precedence.)
>
> For modules:
>
>      - imported_items             (defined in another module,
>                                      or is another module)
>      - classes
>      - functions
>      - other_objects              (everything else)
>
> For classes:
>
>      - from_else_where            (object created someplace else)
>      - inherited_attributes       (from parents classes or type)
>      - static_methods_here
>      - class_methods_here
>      - other_methods
>      - properties
>      - getset_descriptors
>      - other_descriptors
>      - other_attributes           (everything else)
>
> A single function that accepts an object and can return one of the above
> (or equivalent) strings would be ideal.  Finer grained categorizing is ok
> as long as they don't overlap more than one group.
>
> It seems I can get some of these fairly easy with the inspect module, but
> others I need to test in multiple ways.
>
> Any ideas?
>
> Cheers,
>     Ron

Ron,

Consider using epydoc if you can. Epydoc will sort the methods and it
will also let you use custom CSS style sheets for the final HTML
output. Check out the documentation of my PyDBTable module.
http://www.psipy.com/PyDBTable

-Nick Vatamaniuc





More information about the Python-list mailing list