iteration over methods
johnroth at ameritech.net
Tue Jan 7 14:14:37 CET 2003
"Oliver Vecernik" <vecernik at aon.at> wrote in message
news:3E1AB7B3.4050404 at aon.at...
> I've got an object with some methods:
> class Someclass(self):
> def __init__(self):
> def method1(self):
> def method2(self):
> def runallmethods(self):
> for func in dir(self):
> if func[0:4] == 'method':
> apply(self.func) # Does *not* work!
> I'd like to run all methods named 'method...' in a sequence. Has
> a clue how to achive this?
Look at the "unittest" module. It does exactly this.
> Best Regards,
More information about the Python-list