#4405: double/single quotation marks in docstring
----------------------------+-----------------------------------------------
 Reporter:  mvngu           |       Owner:  tba                              
     Type:  defect          |      Status:  new                              
 Priority:  minor           |   Milestone:  sage-3.2.1                       
Component:  user interface  |    Keywords:  docstring, triple ''', triple """
----------------------------+-----------------------------------------------
 At this [http://groups.google.com/group/sage-
 support/browse_thread/thread/1dc6a340db91e7ac sage-support] thread,
 kcrisman reported the following problem with single quotation marks in
 docstring:
 {{{
 I came across some very strange behavior recently regarding docstrings
 in functions.  In the notebook in 3.2.alpha0 and 3.0.6, putting an
 apostrophe in the docstring causes various bugs.  It doesn't have to
 be in any particular spot, as far as I can tell; in fact, it took a
 long time to pinpoint this as the source of the problem!

 More precisely, it seems to cause the preparser to turn off or
 something, because it disallows the following (in the function
 definition):
 f(x)=x^3
 because of the f(x), and
 f=x^3
 because of the ^ used instead of ** (the error message for the first
 is very mysterious at times, but the second one is always clear when
 you try to use the function).

 I can post a link to a worksheet if it's really necessary, but
 hopefully this will be enough for someone to help.  I checked Sage and
 Python docs about documentation strings, but couldn't find anything
 about it being bad to have apostrophes; in fact, some Sage docstrings
 have them (e.g. for declaring variables).  I didn't try this in the
 command line, so it is possible it's only a notebook issue.
 }}}
 Some basic experimentation reveals that it's likely to be caused by the
 use of single quotation marks in docstring from within the console and
 notebook. However, the reported error as described by kcrisman seems to go
 away when double quotation marks are used instead of single quotation
 marks:
 {{{
 OK, here's my experimentation from within the console sage-3.1.4, x86
 machine, Debian 5.0 Lenny (testing):

 Yep, I received a similar error as you described:

 sage: def foo():
 ....:     '''
 ....:     What's up with this? x^3
 ....:     '''
 ....:     f(x) = x^3
 ------------------------------------------------------------
   File "<ipython console>", line 5
 SyntaxError: can't assign to function call (<ipython console>, line 5)

 John's suggestion about replacing the ''' with r''' results in the same
 error:

 sage: def foo():
 ....:     r'''
 ....:     What's up with this? x^3
 ....:     '''
 ....:     f(x) = x^3
 ------------------------------------------------------------
   File "<ipython console>", line 5
 SyntaxError: can't assign to function call (<ipython console>, line 5)

 As Simon has said, the error seems to go away when I used triple "
 (double quotation mark, not single quotation mark), which I normally
 do anyway whenever I write docstring. But using triple ''' with or
 without the leading r, and with or without the question mark, resulted
 in a siimilar error:

 sage: def foo():
 ....:     '''
 ....:     What's up with this? x^3
 ....:     '''
 ....:     f(x) = x^3
 ------------------------------------------------------------
   File "<ipython console>", line 5
 SyntaxError: can't assign to function call (<ipython console>, line 5)

 sage: def foo():
 ....:     r'''
 ....:     What's up here x^3
 ....:     '''
 ....:     f(x) = x^3
 ------------------------------------------------------------
   File "<ipython console>", line 5
 SyntaxError: can't assign to function call (<ipython console>, line 5)
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4405>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to