r/Python • • Jun 08 '10

Python Makes Tedd Nervous

http://teddziuba.com/2008/12/python-makes-me-nervous.html
0 Upvotes

45 comments sorted by

View all comments

6

u/Pyth0nist4 Jun 08 '10

Besides documentation (btw, the online Python documentation is much richer than what you get from the command line help() function), Python calls for you to use tests where you would have relied on the compiler in Java. People who use languages where the compiler does some tests for you don't always realize they still need tests. So the main thing is: if you have don't have extensive tests, you are doing it wrong.

So what kind of exceptions can a Python function/method raise? Basically anything. You build tests for the kinds of things you expect to pass to it, and catch and deal with exceptions that those raise. If anything else gets raised, you need to decide: should you just blindly deal with them and hope for the best, let them percolate up to some other handler who may be able to deal with it, or die. There is no simple answer to this question, and it depends on your app.

2

u/grayvedigga Jun 09 '10

Python calls for you to use tests where you would have relied on the compiler in Java

You're the only person in this thread that has got the point. Well done.

In statically-checked languages, I can have the confidence that a well-written library will make it difficult for me to write seemingly-correct code that misuses it. In Python this is rarely the case.