Hi!
On 20 Jul., 22:58, eggartmumie <[email protected]> wrote:
> def goppapolynomial(F,z): # return a Goppa polynomial in z over ring
> or field F
> X = str(z); R.<X> = PolynomialRing(F);
> return R(X^(N-K));
First of all, the notation R.<X> = F[] will work on the command line,
but will not work in a .py file, because this notation is not Python
syntax, but is a syntactic sugar provided by the Sage preparser. And
of course, it is not possible to use a string instead of an
identifier.
Looking at the documentation (e.g., doing
sage: PolynomialRing?
) you'll find what the "pure python" notation is, and in particular
also to solve the problem of passing an arbitrary variable name. For
instance:
sage: P = PolynomialRing(QQ, 'w')
sage: X = P.gen()
sage: P; X
Univariate Polynomial Ring in w over Rational Field
w
So:
def goppapolynomial(F,z): # return a Goppa polynomial in z over ring
or field F
X = PolynomialRing(F,repr(z)).gen()
return X^(N-K)
should work (supposed that N and K are defined).
Cheers,
Simon
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org