On Jan 24, 2008 9:56 PM, Jason Grout <[EMAIL PROTECTED]> wrote:
>
> mabshoff wrote:
> >
> >
> > On Jan 25, 6:20 am, Jason Grout <[EMAIL PROTECTED]> wrote:
> >> mb wrote:
> >>> Hello,
> >>> Here is a suggestion. The default way to post examples is like so:
> >>> sage: s=0
> >>> sage: for i in range(100):
> >>> ....: s=s+i
> >>> ....:
> >>> sage: print s
> >>> 4950
> >>> I would propose a format that makes it easier to cut and paste (into a
> >>> file), without having to do it line by line, namely
> >>> s=0
> >>> for i in range(100):
> >>> s=s+i
> >>> print s
> >> How do you propose separating input and output?
> >
> > Well, I guess it would only be input ;)
> >
> >> I think it should be pretty easy to write a function that converts the
> >> former form to the latter form. Maybe you can make it a trac ticket?
> >
> > Don't. "sage:" is already eaten by the preparser (you can try that)
> > and the already is a ticket for "....:".
>
> What about the situation the poster describes, where you want to strip
> the example down to something you can stick into the file? A function
> would be nice to do that:
>
> strip_example("""
> sage: s=0
> sage: for i in range(100):
> ....: s=s+i
> ....:
> sage: print s
> 4950
> """)
>
> prints
>
> s=0
> for i in range(100):
> s=s+i
>
> print s
>
>
> and then it's easy to copy and paste the example into a file.
Some comments about this thread:
(1) We're not changing the docstring format for two reasons:
(a) There are now over 40,000 lines of just *input* docstrings in the
main sage library!
teragon:plot was$ sage -grep "sage:" |wc -l
40353
(b) The current format is imposed by Python; it's already the
standard Python docstring
format, and hence we should stick with it.
(2) It is annoying that ipython formats input with a stupid ....:
instead of the ... format like
in Python. Fernando -- why does Ipython do that?
teragon:plot was$ sage -python
Python 2.5.1 (r251:54863, Jan 18 2008, 16:10:52)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for n in range(10):
... print n
...
0
1...
(3) In the Sage notebook, if you make a worksheet, then click "Text"
in the top right area,
you'll get plain text formated for inclusion in docstrings.
--- William
--~--~---------~--~----~------------~-------~--~----~
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-forum
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---