#15989: Python 3 preparation: Change print statement to print() function
--------------------------------+------------------------
       Reporter:  wluebbe       |        Owner:
           Type:  enhancement   |       Status:  new
       Priority:  major         |    Milestone:  sage-6.2
      Component:  distribution  |   Resolution:
       Keywords:  python3       |    Merged in:
        Authors:                |    Reviewers:
Report Upstream:  N/A           |  Work issues:
         Branch:                |       Commit:
   Dependencies:                |     Stopgaps:
--------------------------------+------------------------

Comment (by wluebbe):

 In Sage there are currently only 4 py modules with an {{{from __future__
 import print_function}}}.

 From the [[https://docs.python.org/2/library/functions.html#print|Python
 documentation]]:
   Note: This function <the print() function> is not normally available as
 a built-in since the name print is
   recognized as the print statement. To disable the statement and use the
 print() function,
   use this future statement at the top of your module:
   "from !__future!__ import print_function".
   //New in version 2.6.//

 There are about 50 py modules that contain uses of the print statement
 that look like a function call (i.e. having parenthesis). In some cases
 2to3 will wrap an additional pair of parenthesis around it. But as the
 following snippet shows this should be neither in Py2.7 nor in Py3.3 a
 problem:
 {{{
 Python 2.7.5+ (default, Feb 27 2014, 19:37:08)

 >>> print "text"
 text
 >>> print"text"
 text
 >>> print("text")
 text
 >>> print(("text"))
 text

 >>> from __future__ import print_function
 >>> print"text"
   File "<stdin>", line 1
     print"text"
               ^
 SyntaxError: invalid syntax
 >>> print "text"
   File "<stdin>", line 1
     print "text"
                ^
 SyntaxError: invalid syntax
 >>> print("text")
 text
 >>> print(("text"))
 text
 >>>
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15989#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to