Thoughts on using isinstance

abcd codecraig at gmail.com
Wed Jan 24 09:12:14 EST 2007


> The "Python way" is to validate by performing the operations you need to
> perform and catching any exceptions that result. In the case of your
> example, you seem to be saying that you'd rather raise your own
> exception (which, by the way, should really be a subclass of Exception,
> but we will overlook that) that relying on the interpreter to raise a
> ValueError or a TypeError. Is there really any advantage to this? You
> increase your code size and add *something* to execution time with
> little real purpose.
>
> People coming to Python after C++ or some similar language that allows
> or requires parameter type declarations often don't feel comfortable
> taking this direction to start with, but  it works well for most of us.
>
> regards
>   Steve


So instead of validating input I should just try and use the input as
if it was correct, and let python throw the errors?




More information about the Python-list mailing list