Just an extension of my memory - a way to remember all these little tricks I end up forgetting after a while.. Seen a few people use a blog for this.. seems useful

Monday, March 5, 2012

doctest_mode in iPython

If you want to import code into iPython that has been copied from the python console
or code that is to be run as a doctest in Python Sphinx, a useful trick to use in iPython
is

%doctest_mode

For example:

>>> import numpy as np
>>> some_value = 35
>>> np.sqrt(some_value)


You can copy this directly into iPython and it will treat it like normal python code.
No need having to copy every line of code after >>>

No comments:

Post a Comment