How to iterate through a module's functions [duplicate]
This question already has an answer here: How to list all functions in a Python module? 14 answers I have this function call after importing foo.py. Foo has several methods that I need to call e.g. foo.paint, foo.draw: import foo code if foo: getattr(foo, 'paint')() I need to use a while loop to call and iterate through all the functions foo.paint, foo.draw etc. How do i go about it? You can use foo.__dict__ somehow like this: for name, val in foo.__dict__.iteritems(): # iterate through every module's attributes if callable(val): # check if callable (normally functions) val() # call it But