Nice, this goes into some ground not covered in other python testing discussions. Great code examples. :-) These are the kinds of articles I come to hacker news to find.
This is a really helpful article for me. I'm a programming newb and have been banging out ad hoc code for the last six months. Boy do I have some mega-functions. I've known enough to know that at some point this practice has to change, but I've been a bit stuck as to how to start making improvements. So I'm looking forward to working through this example.
I would like to be able to share this, amiably, with a few of my colleagues and bosses who are not programmers, as we recently had to judge a $half-million piece of software with 2 600 line cashflow functions and I was the only one complaining.<p>But, yeah, look, the article is 'fine', but not much more, and very unfortunately.<p>Does anybody know of a similar article re modularisation with a more transparent example, and a more detailed transition between hypothesis and conclusion? He just seems to say 'less complexity', ???, 'profit'.
Write tests, run code-coverage and code-smells. While good advice, that's just saying what to do. Not how to do. You can as well remove the word Python from the title and the advice holds true in general.<p>What i would like to see :-
what in python we can use that will help us write quality, concise code. Things like using list comprehensions, using magic methods, higher order functions(decorators...) and may be something else that i didn't knew.
I use a similar commenting style, but in addition to the description, arguments and returns, I also list globals used (if any) and side effects (even if none). I find it very helpful to show if a function depends on or alters state.