[Tutor] calling a superclass method after overriding it

Serdar Tumgoren zstumgoren at gmail.com
Wed Sep 23 01:53:38 CEST 2009


>   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


More information about the Tutor mailing list