Can ask a class for its functions?

Peter Hansen peter at engcorp.com
Wed Aug 14 21:53:37 EDT 2002


Troy Melhase wrote:
> 
> 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_)])

Or more simply?

    filter(callable, clazz.__dict__.values())

-Peter



More information about the Python-list mailing list