Refactor code/output in python shell (doctest style)