[Tutor] calling a superclass method after overriding it
Dave Angel
davea at ieee.org
Tue Sep 22 23:24:56 CEST 2009
Serdar Tumgoren wrote:
> <snip>
>
>
> def result_of_SPECIALIZED_SQLcall_for_child():
> name =None
> return name
>
> <snip>
>
> class Child(Parent):
> def __init__(self):
> super(Child, self).__init__()
>
> def add_name(self):
> name = result_of_SPECIALIZED_SQLcall_for_child()
> try:
> name + ''
> self.name =ame
> except TypeError:
> #default to the superclass's add_name method
> super(Child, self).add_name()
>
> Meantime, many thanks!!
>
>
I know this is a simplified example, but I'd still like to point out
that using exceptions when there's a simple test is not reasonable.
You can just check for None with a simple if test.
DaveA
More information about the Tutor
mailing list