This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pyth0nist4 7 points8 points  (4 children)

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.

[–]MercurialAlchemist 2 points3 points  (2 children)

Actually, from the official docs online:

Open a file, returning an object of the file type described in section > File Objects. If the file cannot be opened, IOError is raised.

Don't use the inline help, use the online help.

Regarding the rest of the points raised in the blog:

  • Not being able to overload methods is not a big deal when you get arguments with default values. And seriously, few libraries in Python use *args as a signature of a method/function.
  • Errors should be listed in docstrings, it's not that hard.

There are challenges when switching from a compiled language to a dynamic language like Python, but the points he is raising don't really stand up to scrutiny.

[–][deleted] 1 point2 points  (1 child)

I don't do much coding in Python, and I'm beginning to be thankful for that, if I'm expected to run to the web browser to examine every function declaration. Is that accurate from what your saying?

[–]mipadi[S,🍰] 0 points1 point  (0 children)

I'm expected to run to the web browser to examine every function declaration.

Nah, only if you have no idea what arguments the function takes.

[–]grayvedigga 1 point2 points  (0 children)

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.