I put this together and tested it and it seems to work and does not need any libraries and follows your original intent:
class example:
def __init__(self):
n = self.__class__.__name__
self.method_list = [func for func in dir(eval(n)) \
if callable(getattr(eval(n), func)) \
and func[0]!='_' \
and func!='run_all']
def foo(self):
print("hi")
def bar(self):
print("hello")
def run_all(self):
for m in self.method_list:
runstring = 'self.' + m + '()'
eval(runstring)
Using it:
>> a = example()
>> a.run_all()
hello
hi
all
is a Python command so I renamed your method to run_all
.
func!='run_all'
was necessary so you don't get a nasty recursion situation happening.
This lets you list the methods, I restricted it just so that no private methods get listed.
self.__class__.__name__
gets the name of your class