question with inspect module

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Feb 20 20:00:09 EST 2007


En Tue, 20 Feb 2007 16:04:33 -0300, Tool69 <kibleur.christophe at gmail.com>  
escribió:

> I would like to retrieve all the classes, methods and functions of a
> module.
> I've used the inspect module for this, but inside a given class
> (subclass of some other one), I wanted to retrieve only the methods
> I've written, not the inherited one. How can I do ?

A more direct approach:

   [name for name,value in vars(your_class).items() if  
inspect.isroutine(value)]

This gets you normal, static and class methods. inspect.isfunction would  
return only normal methods, and inspect.ismethoddescriptor static and  
class methods.

-- 
Gabriel Genellina




More information about the Python-list mailing list