Ask Your Question

Revision history [back]

Let me first answer the secont part. When you write PRZp = PolynomialRing(Zp, 'x'), you only define PRZp to be a polynomial ring with the symbol 'x' as an indeterminate, but you did not let the PYthon variable x to point to the polynomial undeterminate 'x'. For this, you can for example do:

sage: x = PRZp.gen()


sage: PRZp.inject_variables()
Defining x

Now, for the first part, the notation PRZp.<x> = Zp[] is indeed not Pythonic, so it works because of Sage preparser that transforms it to something meaningful to Python:

sage: preparse('PRZp.<x> = Zp[]')
"PRZp = Zp['x']; (x,) = PRZp._first_ngens(1)"

So, you can either writh that in your python file, or, if you want to keep the same syntax, you should use a Sage file instead ot a Python file, so that Sage preparser get applied first. The way to do this is to rename into yourfile.sage.