Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python 3 print in Sage

This is a minor issue, but I've long migrated all my Python scripts to Py3, so I'm trying to write in Sage in the most Py3-compliant way possible, since we'll have Py3 support in a not-so-distant future according to the FAQs (frankly I'm a bit surprised that Py3 support haven't already happened, but, oh well).

Anyway, because of that I put from __future__ import print_function, division in the very first line of my init.sage.

If I type things interactively in the prompt, it works as it's supposed to:

sage: print('C_r' ,6)
C_r 6

However, if I run a script with load('my_script.sage') it prints things as if I was using Py2.

('C_r', 6)

Am I loading my scripts wrong? How can I get it to work for scripts too?