On Sun, 28 Jan 2007 15:26:56 -0800, Timothy Clemans <[EMAIL PROTECTED]> wrote:

>
> Just to show that something bad seems to be happening, I looked up the
> source for prime_pi and copied it into a cell and changed the name to
> epi. Well I added print epi(300) and got 0. I also added print "Hello"
> and got nothing. In another cell I typed prime_pi(300) and got 62. So
> I'm sure that there is a bug in SAGE notebook with docstrings in
> personal code.

You're absolutely right.  This is a bug in the SAGE notebook, or rather,
and unforseen "feature".  In the notebook if an input cell line starts
with either "sage:" or ">>>", then the input is viewed as an example
that was likely pasted in, and *only* the lines that begin with sage:
are evaluated.  (The parser that checks for this doesn't take into
account triple-quoted strings!)   Unfortunately this leads to the
following sort of stupid behavior:

{{{
def foo(x):
     """
     EXAMPLES:
         sage: 2+2
         4
     """
     return x
///
4
}}}

{{{
foo(5)
///
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/server/sage_notebook/worksheets/_uniqued/code/13.py", line 4, in 
<module>
     exec compile(ur'foo(Integer(5))' + '\n', '', 'single')
   File "/home/server/", line 1, in <module>

NameError: name 'foo' is not defined
}}}

This is now trac #228:

    http://sage.math.washington.edu:9002/sage_trac/ticket/228

THANKS for reporting this bug!

  William


>
> On 1/28/07, Timothy Clemans <[EMAIL PROTECTED]> wrote:
>> On http://sage.math.washington.edu:8100/_uniqued , my first cell
>> produces the error:
>> Syntax Error:
>>      v = primes_first_n(n)
>> The second cell does not produce an error. The only difference between
>> the code in the two cells is that in the first I have the docstring:
>>  r"""
>>  EXAMPLES:
>>      sage: for i in range(len(uniqued(4))):
>>      ....:     print len(uniqued(h)[i]),
>>      14 , 5 , 2 , 8 ,
>>  """
>>
>> How do I write my own docstrings and not produce errors like this one.
>>
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to