Ask Your Question
1

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

asked 8 years ago

Byungyun Jeon gravatar image

updated 0 years ago

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
    file.write(data)
    file.close()
    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?

Preview: (hide)

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
1

answered 8 years ago

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.

Preview: (hide)
link

Comments

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

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

slelievre gravatar imageslelievre ( 8 years ago )

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 420 times

Last updated: Aug 17 '16