bundles / IPython latest / IPython / core / magics / basic / BasicMagics / doctest_mode
function
IPython.core.magics.basic:BasicMagics.doctest_mode
Signature
def doctest_mode ( self , parameter_s = '' ) Summary
Toggle doctest mode on and off.
Extended Summary
This mode is intended to make IPython behave as much as possible like a plain Python shell, from the perspective of how its prompts, exceptions and output look. This makes it easy to copy and paste parts of a session into doctests. It does so by:
Changing the prompts to the classic
>>>ones.Changing the exception reporting mode to 'Plain'.
Disabling pretty-printing of output.
Note that IPython also supports the pasting of code snippets that have leading '>>>' and '...' prompts in them. This means that you can paste doctests from files or docstrings (even if they have leading whitespace), and the code will execute correctly. You can then use '%history -t' to see the translated history; this will give you the input after removal of all the leading prompts and whitespace, which can be pasted back into an editor.
With these features, you can switch into this mode easily whenever you need to do testing and changes to doctests, without having to leave your existing IPython session.
Aliases
-
IPython.core.magics.BasicMagics.doctest_mode