Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sagetex representation should align with sagemath CLI output, hence catch stdout #63

Open
meisterluk opened this issue Nov 19, 2022 · 3 comments

Comments

@meisterluk
Copy link

Expected output

sage: print('Hello World')
Hello World

Actual output

sage: print('Hello World')
None

Proposed solution

It is annoying that the output in sagemath CLIs/cells is different from the sagemath generated output.

  • As far as I understand, eval and preparse are called to generate the output. The output is written to result. Then only result is represented, not what was written to stdout.
  • With python3, print became a function and thus the problem occurs with one of the most fundamental primitives. Thus, it is IMHO particularly annoying.
  • Simutaneously, it is easy to manipulate stdout, catch the written content and represent it in sagetex
  • Thus, I propose to replace sys.stdout during execution, represent the caught lines and skip representation of the result if it is None
@kcrisman
Copy link
Member

kcrisman commented Nov 29, 2022 via email

@meisterluk
Copy link
Author

I cannot speak for the entire community, but my personal take is …

  • The output will change. Since there is no mechanism to communicate output changes across versions on CTAN, one might soften the blow with an optional flag. Per default, you get the previous behavior. Enabling the option, the output is caught as I described initally. If the community prefers it in general, the behavior will become default some years later and an option allows to get the old behavior.
  • I submitted this bug report, because a user in a talk described how much annoyance this created for her. As someone with limited technical knowledge, she did not know what is going on. I looked into the technical details. So this comes from the community itself.
  • I cannot see a problem with processing time. But the memory usage increases. This is an argument in favor of an optional flag instead of non-optional future behavior.

@meisterluk
Copy link
Author

I learned that the request might be a direct result of Cryptool, a software and its German book about cryptography which uses sagetex for generating its content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants