Opened 5 years ago

Closed 3 years ago

#20668 closed enhancement (fixed)

Turn on python3 print function

Reported by: chapoton Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: python3 Keywords:
Cc: vbraun, jdemeyer, embray Merged in:
Authors: Frédéric Chapoton Reviewers:
Report Upstream: N/A Work issues:
Branch: public/20668 (Commits, GitHub, GitLab) Commit: 904abca8baaa8475835699243cdce32407f9f96b
Dependencies: Stopgaps:

Status badges

Description (last modified by chapoton)

The aim of this ticket is to use the Python 3 print() function everywhere in Sage: doctests, command-line, notebook.

STATUS (2016-05) after discussions on sage-devel, this ticket is not going to be merged until a complete switch to python3 is effected.

It will be kept open to let the patchbots monitor the possible failing doctests that would be triggered by enforcing python3 print syntax.

Change History (25)

comment:1 Changed 5 years ago by chapoton

  • Branch set to public/20668
  • Commit set to 904abca8baaa8475835699243cdce32407f9f96b

New commits:

904abcatrac 20668 activation of the py3 print function behaviour

comment:2 in reply to: ↑ description ; follow-up: Changed 5 years ago by jdemeyer

  • Summary changed from turn on globally the python3 print function to turn on python3 print function in doctests

We should only do this if we also change the Sage command line to use Python 3 print() syntax. Doctests and the command line should be consistent.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 5 years ago by chapoton

Replying to jdemeyer:

We should only do this if we also change the Sage command line to use Python 3 print() syntax. Doctests and the command line should be consistent.

But this is obviously the goal. Why did you change the title of the ticket ?

comment:4 in reply to: ↑ 3 Changed 5 years ago by jdemeyer

Replying to chapoton:

But this is obviously the goal. Why did you change the title of the ticket ?

I guess I misunderstood the goal of this ticket then... maybe you should clarify the title and description of what you want to achieve.

comment:5 Changed 5 years ago by chapoton

  • Description modified (diff)

comment:6 Changed 5 years ago by chapoton

  • Description modified (diff)

comment:7 follow-up: Changed 5 years ago by jdemeyer

  • Description modified (diff)
  • Summary changed from turn on python3 print function in doctests to Turn on python3 print function

This is an important change which must obviously be discussed on sage-devel first.

comment:8 in reply to: ↑ 7 Changed 5 years ago by chapoton

Replying to jdemeyer:

This is an important change which must obviously be discussed on sage-devel first.

Yes, for sure.

comment:9 Changed 5 years ago by chapoton

I made a first sketch of wiki page here:

https://wiki.sagemath.org/PrintFunction

comment:10 Changed 5 years ago by chapoton

  • Description modified (diff)

I changed the description, according to the discussion here: https://groups.google.com/forum/#!topic/sage-devel/DrMJtNQid6s

comment:11 Changed 5 years ago by chapoton

I wonder: would it be difficult to turn on the python3 print when running the doctests of sage ? I think that this would be very useful to prevent new introductions of bad print syntax.

comment:12 Changed 4 years ago by chapoton

  • Milestone changed from sage-7.3 to sage-duplicate/invalid/wontfix

comment:13 Changed 4 years ago by embray

Any reason for that change?

This still seems like a good idea to me? At some point Sage is going to have to switch to Python 3 (Python 2 support ends 2020). Good to start now...

comment:14 Changed 4 years ago by vbraun

+1 million ;-)

comment:15 Changed 4 years ago by embray

What I mean is the change to the milestone.

comment:16 Changed 4 years ago by chapoton

Well, the switch to python3 will happen once the code is entirely compatible, and this is not for tomorrow, given that not so many people actively work on the problem.

Besides, we are not going to force python2 users to use python3-sage. So this ticket is useful only for its branch, that allows from time to time to see that somebody has once again re-introduced a python2 print somewhere.

comment:17 Changed 4 years ago by embray

I see.

I just meant it would be good to start pushing the print() function on people anyways :)

comment:18 follow-ups: Changed 4 years ago by vbraun

But it should be enabled for doctests; Just add the print_function import to src/sage/doctest/sources.py as virtual doctest.

comment:19 in reply to: ↑ 18 Changed 4 years ago by tscrim

Replying to vbraun:

But it should be enabled for doctests; Just add the print_function import to src/sage/doctest/sources.py as virtual doctest.

+1 to doing this.

comment:20 Changed 4 years ago by chapoton

Please do that if you can, I cannot.

comment:21 in reply to: ↑ 18 Changed 4 years ago by chapoton

Replying to vbraun:

But it should be enabled for doctests; Just add the print_function import to src/sage/doctest/sources.py as virtual doctest.

Volker, what do you mean exactly, please ? Do we just need to add one single line

from __future__ import print_function

in the code of the file src/sage/doctest/sources.py or is there something more subtle to do ? ( I have no idea of what is a "virtual doctest")

comment:22 Changed 4 years ago by chapoton

ping ? Please, Volker, what do you mean exactly by comment:18 ?

comment:23 Changed 4 years ago by vbraun

Enabling print_function in doctests is now #23551

comment:24 Changed 3 years ago by chapoton

Erik, could you please close this one ?

comment:25 Changed 3 years ago by embray

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.