1 | initial version |

This may not be the best way to recover a polynomial from its string representation but it appears to work.

Say `p = R.random_element(degree=2,terms=+infinity)`

, then `s = str(p)`

gives you its representation as a string. To recover `p`

you can try `q = R( eval(s))`

. Then `p==q`

should evaluate to `True`

.

2 | No.2 Revision |

This may not be the best way to recover a polynomial from its string representation but it appears to work.

Say `p = R.random_element(degree=2,terms=+infinity)`

, then `s = str(p)`

gives you its representation as a string. To recover `p`

you can try `q = R( eval(s))`

. Then `p==q`

should evaluate to `True`

.

Now, if you are reading a file `fr`

with a polynomial per line, you can try the following to recover the polynomials.

```
vars = ['x'+str(i) for i in range(10)]
R= BooleanPolynomialRing(names=vars)
R.inject_variables()
polys = [ R(eval(l[:-1])) for l in fr]
```

Update: Added iteration through file.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.