[Tutor] Learning to program, not code.

Ben Finney ben+python at benfinney.id.au
Sun Dec 21 11:15:43 CET 2014


Albert-Jan Roskam <fomcl at yahoo.com.dmarc.invalid> writes:

> Don't postpone writing unittests (don't use doctest). They really give
> you focus and confidence (peace of mind!).

Excellent advice. Write unit tests as a way of documenting what you want
the function to do, and also to document what the function did wrong
in that bug you just found :-)

(Although, I'd modify the above to: do use doctest, but *not* for unit
tests. Use doctest only for testing code examples you already have in
your documentation, it's good for that.)

> If you also use version control, you can automatically run all tests
> before each commit.

There's no “if” there. Use a distributed version control system
(Mercurial is good and is written in Python), and always make small
easily-described commits while working.

-- 
 \        “Visitors are expected to complain at the office between the |
  `\                     hours of 9 and 11 a.m. daily.” —hotel, Athens |
_o__)                                                                  |
Ben Finney



More information about the Tutor mailing list