"print" statement vs function for Sage-py3

asked 6 years ago

dsejas gravatar image

updated 5 years ago

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!

Preview: (hide)

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 ( 6 years ago )

My advice: start using python3 print right now.

FrédéricC gravatar imageFrédéricC ( 6 years ago )

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 ( 6 years ago )