[Tutor] calling a superclass method after overriding it

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


>>>            self.name =ame
>
> I assume this is a typo? And it never gets executed because the error is
> always raised.

yep. that was a typo that should be "name"

> I don't mind using exceptions for a simple test but not where the test is
> being forced by a piece of code that does nothing. In this case I agree it
> would be better to check explicitly for a string if a string is required.

I am indeed trying to check if it's a string.
>
>  if type(name) != str:
>       super(....)
>  else:
>       # other stuff here
>
> is clearer still
>

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


More information about the Tutor mailing list