On 2/21/12 11:42 AM, William Stein wrote:
On Tue, Feb 21, 2012 at 9:38 AM, Starx<[email protected]> wrote:
But what if I don't want to add "from ... import *" at the beginning of each
docstring ?
I had this issue recently. William informed me that the philosophy of
doctests is that a user should be able to take anything they see in a
doctest and type it directly into sage with no additional commands.
So if your file has to be loaded or imported or whatever in order to
make those commands run then that load/import should be present in the
doctests, that way any user reading those doctests will know that they
need to import your file before they can use it.
I think this is a very defendible position too. Isn't it frustrating
when you look at an example, and it has all kinds of hidden
assumptions, so copy/paste of it doesn't "just work". For example, in
numpy docs, one often sees the implicit assumption that one did
"import numpy as np" or "from numpy import *".
I think it makes sense in numpy, scipy, or matplotlib, where you are
documenting a package that is not importing a huge number of things by
default, to have a "standard" import of import numpy as np, etc. Sage
is different because we import everything under the sun into the global
namespace.
Jason
--
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/sage-support
URL: http://www.sagemath.org