[Tutor] Most pythonic input validation
Dave Angel
davea at ieee.org
Sat Oct 17 04:41:45 CEST 2009
Kent Johnson wrote:
> <snip>
>
>
>> Is this the way to define my own error and to use it:
>>
>> class MyValueError(Exception):
>> define initialization and printing
>>
>
> You usually don't need to define anything extra, the Exception methods are fine.
>
>
>
I think there could be confusion over what you meant was unnecessary.
It's a "good thing" to define MyValueError(Exception), but it's usually
unnecessary to give it a body, because the methods it inherits from
Exception are usually just fine.
DaveA
More information about the Tutor
mailing list