I have a class function in Python that either returns a success or a failure, but in case of a failure I want it to send a specific error string back. I have 3 approaches in mind:
- Pass in an variable error_msg to the function originally set to None and in case of an error, it gets set to the error string. eg: - if !(foo(self, input, error_msg)): print "no error" else: print error_msg
- Return a tuple containing a bool and error_msg from the function. 
- I raise an exception in case of an error and catch it in the calling code. But since I don't see exceptions being used often in the codebase I am working on, so was not too sure about taking this approach. 
What is the Pythonic way of doing this?
 
     
    