Serdar Tumgoren wrote:
Exactly. The whole point of forgiveness/permission is to be able to propagate the error without having other code in the path affected by it. So if you return at all, return a real value. (Raise isn't exactly returning, the way I see it, since the flow of control goes elsewhere)def add_name(self): try: self.name = SPECIALIZED_SQLcall_for_child() except SpecialSQLError: #default to the superclass's add_name method super(Child, self).add_name()That certainly is a lot easier to read. So if I were to go that route, would my "SPECIALIZED_SQLCall_for_child()" function (I've slightly renamed it) have to resemble something like below?: def SpecialSQLcall_for_child(): result = execute some sql_for_special_case() if type(result) != str: raise SpecialSQLError else: return result
BTW, it's possible that "execute_some_sql...()" might itself be raising the exception. In this case, we might make this call even simpler; it needn't even know anything about the exception.
DaveA _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
