Can you recommend a nice way of checking a particular value between calls to a set of functions?
E.g. something like this in Python (might not be terribly 'Pythonic'):
self.error_code = 0 # this will be set by each function if an error has occurred self.function_list = [self.foo, self.bar, self.qux, self.wobble] ... def execute_all(self): while not self.error_code and self.function_list: func = self.function_list.pop() # get each function func(error_code) # call it if self.error_code: # do something
The idea is that subsequent functions won't be called if
self.error_code is set and all functions will be called in order if all is good.
Anyone can think of a better alternative to that in Python or maybe a language-agnostic approach?
I want to avoid having that code in each function call (e.g.
if self.error code: return) so that I don't end up with the same check across all functions.