In order to allow your docstring examples to refer to names defined in the current module, doctest-mode saves the current contents of the python-mode buffer to a temporary file; and then imports that file. If your docstring examples refer to names that are not defined in the current module, then you should include appropriate import statements in the doctest examples. |
def x_intercept(m, b): """ Return the x intercept of the line y=m*x+b. >>> import math >>> x_intercept(3, 6) -2.0 >>> x_intercept(-4, mat.sqrt(4)) 0.5. """ return -float(b)/m ISO8---Emacs: mytest.py (Python[Doctest] MMM Font)----L8--All-- |