"print" statement vs function for Sage-py3

asked 2019-04-02 15:56:46 -0500

dsejas gravatar image

updated 2019-06-13 06:32:02 -0500

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

Comments

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-02 17:58:25 -0500 )edit

My advice: start using python3 print right now.

FrédéricC gravatar imageFrédéricC ( 2019-04-03 04:10:36 -0500 )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 05:45:29 -0500 )edit