Can ask a class for its functions?

Peter Hansen peter at engcorp.com
Thu Aug 15 03:53:37 CEST 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