#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 made another attempt using {{{2to3 -f print}}}: this uses no {{{from
__future__ import print_function}}} but changes the print statement syntax
to the print function syntax.
[[br]]
The hope was that the majority of changes would also be valid statement
syntax (just an extra pair of parenthesis). See ticket:13255 for such an
approach.
There were about 200 changed py modules.
[[br]]
Thereof about 20 had lines with {{{end=" "}}}. Some could be eliminated
with a little refactoring.
14 modules needed {{{import print_function}}}. This lead usually 40
doctest failures as the parenthesis caused the parameters to be printed as
tuples (which was not the expected output). A fix would be simple.
But in {{{src/sage/modular/etaproducts.py}}} and in
{{{src/sage/modular/all.py}}} (which contained the only {{{file=}}} the
{{{import print_function}}} caused 2545 doctest failures in about 500
modules!!! I still cannot explain this differing behavior.
**To long didn't read:**
I consider this experiment failed!
[[br]]
If the goal is one **robust** common Python 2 / 3 code base (which I
assume!) then all modules should have the {{{from __future__ import
print_function}}}. This would require a preparser that can add the
parenthesis in the doctests on the fly or -as a fallback- add the
parenthesis to the doctest source.
--
Ticket URL: <http://trac.sagemath.org/ticket/15989#comment:8>
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.