Comment #3 on issue 1591 by smichr: More strict doctests
http://code.google.com/p/sympy/issues/detail?id=1591
I could go either way. But before we release the Doctest Nanny here is a
question I
have: if the user is to be able to copy and paste then what about the case
where code
snippets appear in discontiguous parts of the docstring? I presume that the
snippets
are to be interpreted as being contiguous so that an import done once at
the top of
the docstring is sufficient for the rest of the docstring, e.g.
"""
Here is the first example,
>>> from sympmy import var
>>> var('x')
x
>>> x+1
1 + x
And later,
>>> var('y')
y
>>> x-y
x - y
I am assuming that one wouldn't have to do/show the import again in the 2nd
snippet...and if not, if someone copies that lower snippet, it won't "just
work" like
intended. They will have to scan back through the docstring to see exactly
what the
context is. And that's the part that is prone to human error.
Perhaps what would be better is a function that would spit out the code
samples from
a docstring as one contiguous piece with comments converted to inline
comments,
somewhat like inspect can do(?) for code. And if we can do that we can also
throw in
the relevant imports that would have been executed to make the code snippet
work when
doctest tested it in its normal manner.
o this allows doctest to do its normal magic
o would be something that could be used in all ide's, not only ipython
o it's less error prone
So, for example,
"""
example one
>>> var('x')
x
example two
>>> print x+1
1 + x
"""
becomes something like:
"""
from sympy import * <<or whatever it should be>>
# example one
var('x')
# example two
print x+1
"""
/c
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---