#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):

 I took the following approach:
 1. Run {{{futurize -f print_with_import.py}\}.
    This changed about 200 py modules.
 1. Run the doctests.
    There were failures in about 480 .py/.rst-files. The file with the
 failures had almost 40.000 lines.
 1. I started (slowly) to fix the doctests by wrapping the print parameters
 in parenthesis.
 But the I began to doubt whether this is the right thing to do:
 * Doctests are not only about //test// but also about //documentation//!
 * William Stein made a case (https://groups.google.com/d/msg/sage-
 devel/r-85whQZGhY/72FfjeFt6Z4J) for enabling the preparser to change print
 statements to print functions as required.
 Now I think it would better to
 * First enable the preparser to change the print statement syntax into the
 function syntax whenever "print" refers to '<built-in function print>'
 (which is the case in Py3 but also in Py2 when {{{from __future__ import
 print_function}}} is in effect).
 * Then add parenthesis to the print statements in the py modules (adding
 {{{from __future__ import}}} is optional).
 * If required (because of ">>>file" or a trailing comma) use the new
 function syntax with {{{from __future__ import print_function}}}.
 * Doctest should by changed if and when considered reasonable.

--
Ticket URL: <http://trac.sagemath.org/ticket/15989#comment:6>
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