June 2017
Beginner to intermediate
274 pages
6h 49m
English
Now, what happens if a doctest fails, but after looking at it we see that the documentation and example are actually correct? Well, that means our code is incorrect. Believe it or not, this is a very good thing. I don't mean that having an error is a good thing, but that error was there whether we found it or not. Finding it and having a test on hand that will let us check whether we've succeeded in fixing it, though, is definitely good.
So, doctest ties our code and documentation together, so that they stay synchronized and serve to double-check each other. That's a very useful docstring trick.
Read now
Unlock full access