Can ask a class for its functions?

Troy Melhase troy at gci.net
Thu Aug 15 03:43:51 CEST 2002


This doesn't work because dir() returns a list of strings, none of which are 
callable.

What you meant was:

        filter(callable, [getattr(class_, attr) for attr in dir(class_)])

Carl Banks wrote:

> Matt Gerrans wrote:
>> Yes, you can use dir(classname) or you can access its dictionary like so:
>> classname.__dict__
> 
> 
> filter(callable,dir(classname))
> 
> Otherwise, you get stuff that isn't methods.
> 
> 

-- 
Troy Melhase
mailto:troy at gci.net
http://melhase.com/




More information about the Python-list mailing list