Why static typed languages are sometimes better.

Roy Smith roy at panix.com
Thu Jul 1 17:43:56 EDT 2004


I just had an interesting little surprise.  I've got a method that takes 
a string as an argument.  I wanted to change it to take either a string 
or a tuple of strings, so I did my usual "test first" thing.

I changed the unit test I already had from calling it with a string to 
calling it with tuple of two strings.  I then ran the test, expecting it 
to fail.  The next step would be to go write the code to make the test 
pass.

Amazingly, the test passed (that means I'm done, right?).  Well, it took 
me a moment to realize that the only thing I ever do with the argument 
in the current version is use it as a dictionary key.  Since a tuple of 
two strings is a valid key, so the test passed just fine.  Sometimes the 
language is just too forgiving :-)



More information about the Python-list mailing list