Closed dsejas closed 5 years ago
IMHO everything that one needs to import from __future__
is already imported by Sage itself, no?
Not completely true! On one hand, Sage makes some from __future__
imports internally, but, on the other hand, they are not available while using SageTeX. The user has to explicitly make their imports. As a particular case, Sage makes from __future__ import print_function
in many parts of its code, but the user has only the print
statement available. If they want to use the print
function, the import must be manually made in the user layer.
Thanks for clarification. Sage is switching to Python 3 --- in particular as many of its dependencies already did so or will by 2020. The upcoming 8.9 should already be useful with Python 3. I'd rather not touch specifically Python 2 things - in partiular modifyng desigm to support Python 2 better is very low on the priorites list.
Description: When using SageTeX, trying to make
from __future__
imports from asagesilent
environment produces the following error message:Version: SageTeX v3.2, dated 2019/01/09; SageMath v8.8; TeXLive 2019. How to reproduce: The following MWE tries to make a
from __future__ import print_function
as soon as SageTeX allows it (after\begin{document}
:Possible cause: The .sty file has the following lines:
This already starts the main .sage file with some imports. This causes the first time we use the
not to be the first import, producing the error message.
Possible solution: Define an new environment "sageimports" or "sagepreamble" that adds its code just before the
import sage
of the lines mentioned in the possible cause section.