There's definitely syntax rules that need to be followed, e.g. skipping lines to intermingle comments and statements and outputs:

http://docs.python.org/2/library/doctest.html