[Tutor] calling a superclass method after overriding it

ALAN GAULD alan.gauld at btinternet.com
Wed Sep 23 01:49:33 CEST 2009



> In this case, is there any argument against checking for None? Or is
> it better to do a type check for a string?
> 
> if name is None:
>     super(....)
> else:
>     # do stuff


That might be ok if string or None are the only types you could get.
Checking for not string will catch any numbers, booleans or anything 
else that might slip through...

Basically check for what id most accurately representing what 
you want. If you want to catch anything other than a string use
an explicit string test, if you only want to catch None then check 
for None.

Alan G.



More information about the Tutor mailing list