Ask Your Question

Revision history [back]

Hi,

The syntax S.<x>=..., which is not standard Python, is actually interpreted by the Sage preparser. You can find how it is transformed to standard Python by means of the preparse command, with "S.<x>=..." as an argument (don't forget the quotes):

preparse("S.<x> = NumberField(x^2-5)")

The output is

"S = NumberField(x**Integer(2)-Integer(5), names=('x',)); (x,) = S._first_ngens(1)"

As you can see, it is a short-cut ("syntactic sugar") for combining two definitions into a single instruction: the definition of S and that of x, as a generator of S.

This is documented in Sage reference manual: look for sage.repl.preparse.preparse_generators in this page