Testing dynamic languages

Martin P. Hellwig martin.hellwig at dcuktec.org
Sat Apr 4 15:59:16 CEST 2009

grkuntzmd at gmail.com wrote:
> If I am writing in Python, since it is dynamically, but strongly
> typed, I really should check that each parameter is of the expected
> type, or at least can respond to the method I plan on calling ("duck"
> typing). Every call should be wrapped in a try/except statement to
> prevent the method (and program) from crashing when my method is
> called with an integer instead of the expected string.

Logically speaking, you only need one try/except at the very top of the 
program if you only want to catch these things, but that would be a 
really, really, really bad advice.

I wonder if it wouldn't be better to design the program in such a way 
that the original input is handled in a way that it doesn't conflict 
with what you want to do with.


More information about the Python-list mailing list