iteration over methods

Oliver Vecernik vecernik at
Tue Jan 7 13:12:12 CET 2003

Padraig Brady schrieb:
> How about:
> class Someclass:
>     def __init__(self):
>         pass
>     def method1(self):
>         pass
>     def method2(self):
>         pass
>     def runallmethods(self):
>         for name, func in self.__class__.__dict__.items():
>             if name[0:6] == 'method':
>                 func(self)

Well, I just see:


But I didn't tell the whole story. Actually this class is subclassed:

class Subclass(Someclass):
     def __init__(self):

def main():
     ref = Subclass

All other methods are inherited from 'Someclass'. Sometimes 'Subclass' 
may overload some methods, but in general they should be inherited. Is 
there also a possiblity to iterate over all of them?

Best Regards,

More information about the Python-list mailing list