Ask Your Question

Revision history [back]

By "this result" I assume you mean the one numbered Out[14] in the screen capture.

There is no need for any extra parentheses around exponents.

Copying and pasting this to a new file should work.

Or you could write to a file and then read from a file using Python functionality.

Something like the following should work.

Write:

with open('my_polynomials.txt', 'w') as f:
    f.write(my_list_of_polynomials)

Read:

P = PolynomialRing(QQ, ['w', 'x', 'y', 'z'])

with open('my_polynomials.txt', 'r') as f:
    s = f.read()
polynomials_as_strings = s[1:-1].split(',')
polynomials = [P(p) for p in polynomials_as_strings]

By "this result" I assume you mean the one numbered Out[14] in the screen capture.

There is no need for any extra parentheses around exponents.

Copying and pasting this to a new file should work.

Or you could give the result a name and save it to a "sage object" file.

my_polynomial_tuple = ..., ..., ...
save(my_polynomial_tuple, 'my_polynomials.sobj')

Then read it from a different file

my polynomial_tuple = load('my_polynomials.sobj')

Or you could write the output to a file and as a string, and then read it back from a file using that file, using Python functionality.

Something like the following should work.

Write:

with open('my_polynomials.txt', 'w') as f:
    f.write(my_list_of_polynomials)
f.write(my_polynomial_tuple)

Read:

P = PolynomialRing(QQ, ['w', 'x', 'y', 'z'])

with open('my_polynomials.txt', 'r') as f:
    s = f.read()
 polynomials_as_strings = s[1:-1].split(',')
polynomials = [P(p) for p in polynomials_as_strings]