"print" statement vs function for Sage-py3

asked 2019-04-02 22:56:46 +0200

dsejas gravatar image

updated 2019-06-13 13:32:02 +0200

FrédéricC gravatar image

With the upcoming migration of Sage from Python2 to Python3, I was wondering if Sage's default new behavior will be the current print statement (e.g., print 'hello') or will it change to Python3's print command (e.g., print('hello')).

In case of a change from the current behavior, will there be a way to keep backwards compatibility for code written Python2-style?

Thanks for your answers!

edit retag flag offensive close merge delete


There is no resolution about this with respect to user code. It has been discussed at https://trac.sagemath.org/ticket/23674.

John Palmieri gravatar imageJohn Palmieri ( 2019-04-03 00:58:25 +0200 )edit

My advice: start using python3 print right now.

FrédéricC gravatar imageFrédéricC ( 2019-04-03 11:10:36 +0200 )edit

Personally, I think we should change to using the print function by default on Python 2 as well, but it's hard to make that change without at least slightly breaking users' code. Perhaps we could start issuing a warning and tell users that they should add from __future__ import print_function to their sage startup profiles.

Iguananaut gravatar imageIguananaut ( 2019-04-03 12:45:29 +0200 )edit