Is there a way to loop through and execute all of the functions in a Python class?

Posted by curious on Stack Overflow See other posts from Stack Overflow or by curious
Published on 2010-04-08T05:51:15Z Indexed on 2010/04/08 5:53 UTC
Read the original article Hit count: 210

Filed under:

I have

class Foo():
    function bar():
        pass

    function foobar():
        pass

Rather than executing each function one by one as follows:

x = Foo()
x.bar()
x.foobar()

is there a built-in way to loop through and execute each function in the sequence in which they are written in the class? It doesn't matter whether the solution is to add code to the class Foo(), or to do something to x.

© Stack Overflow or respective owner

Related posts about python