grkunt...@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. > > Is this the experience that Python programmer (of large projects) see? > Do you also write unit tests to confirm that the methods actually > check for and catch "bad" parameter types? If I am writing small one- > off scripts, I wouldn't worry about it, but if I am writing a large > system that must have 99+% uptime without constant monitoring, this > really should be verified.
if you are going to do that, stay with java. seriously - i too, am a java developer about half the time, and you can make java pretty dynamic if you try hard enough. look at exploiting aspects and functional programming libraries, for example. the standard solution to what you describe (which is itself a standard problem with dynamic languages) is unit testing. proponents of dynamic languages argue that you need to do testing anyway for its other advantages. proponents of statically typed languages argue that you need to write more. the best solution is probably to use a better language (like ocaml or even haskell) (and i am only half joking). asserting types isn't really going to work once you start exploiting just what python can do (although look at abstract base classes - abcs - which make things easier). personally, i find that i write slightly more tests in python than java and that my python code is, to be honest, slightly less reliable. i also add type assertions at critical points when refactoring (but otherwise not). so in summary: - yes it's an issue - solve it with more unit testing, not type assertions - use the right tool for the job (which might be java) all the above just my experience. i tend to use java for the server side and python for getting data into the database, so each plays to its strengths. andrew -- http://mail.python.org/mailman/listinfo/python-list