Ask Your Question

Get Sage output on Python 2.7 without writing files [closed]

asked 2016-08-12 09:26:23 +0200

Byungyun Jeon gravatar image

updated 2022-01-21 21:42:37 +0200

FrédéricC gravatar image

I have python 2.7 codes and I know that a random python cannot use sage as a python library. So I made a script .sage in python 2.7 and ran check_output command as follows.

from subprocess import check_output 
def sage_code_run(var)
    file = open("/path/to/file.sage", 'w')
    data = "sage codes with input %s" % var
    return check_output(["sage", "file.sage"])

It works well, but it makes delay because of writing files. And I know "sage -python", but it's not for 2.7. Is there a way to get sage output on python?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Byungyun Jeon
close date 2016-08-17 21:20:23.367181

1 Answer

Sort by » oldest newest most voted

answered 2016-08-17 00:26:21 +0200

slelievre gravatar image

What do you mean, sage -python is not for 2.7? Sage's Python is Python 2.7.10.

Upgrading to Python 2.7.12 is the object of Sage trac ticket #19735 and upgrading to Python 3 is the object of Sage trac ticket #16052.

edit flag offensive delete link more


@slelievre: Thanks for comments. I meant python 2.7.12. In my old sage, it was 2.6.4. I didn't know that the latest sage has 2.7.10. I closed this question.

Byungyun Jeon gravatar imageByungyun Jeon ( 2016-08-17 21:18:38 +0200 )edit

What version of Sage did you have? You should install SageMath 7.3.

slelievre gravatar imageslelievre ( 2016-08-18 10:43:51 +0200 )edit

Question Tools

1 follower


Asked: 2016-08-12 09:26:23 +0200

Seen: 308 times

Last updated: Aug 17 '16