Check for the type of arguments

Chris Angelico rosuav at gmail.com
Sat Aug 17 09:31:05 EDT 2013


On Sat, Aug 17, 2013 at 1:34 PM, Fernando Saldanha <fsaldan1 at gmail.com> wrote:
> Writing in other languages I usually check the type and values of function arguments. In the Python code examples I have seen this is rarely done.
>
> Questions:
>
> 1) Is this because it would be "unpythonic" or just because the examples are not really production code?

It's unpythonic. The normal thing to do is simply use the object
you're given, and if something goes wrong, the exception will have a
full traceback. And if you don't notice that it isn't what you expect,
well, it probably didn't matter!

ChrisA



More information about the Python-list mailing list