Ask Your Question

Revision history [back]

Indeed, this is not Python, it is SageMath only. Sage preparses this notation and turns it into Python code:

sage: preparse('R.<w> = PolynomialRing(QQ)')
"R = PolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1)"

Other examples include:

sage: preparse('2/3')
'Integer(2)/Integer(3)'
sage: preparse('2./3')
"RealNumber('2.')/Integer(3)"
sage: preparse('x^x')
'x**x'

See also the documentation of

sage: preparser?

Indeed, this is not Python, Python syntax, it is SageMath syntax only. Sage preparses this notation and turns it into Python code:

sage: preparse('R.<w> = PolynomialRing(QQ)')
"R = PolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1)"

Other examples include:

sage: preparse('2/3')
'Integer(2)/Integer(3)'
sage: preparse('2./3')
"RealNumber('2.')/Integer(3)"
sage: preparse('x^x')
'x**x'

See also the documentation of

sage: preparser?

Indeed, this is not Python syntax, it is SageMath syntax only. Sage preparses preparses this notation and turns it into Python code:

sage: preparse('R.<w> = PolynomialRing(QQ)')
"R = PolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1)"

Other examples include:

sage: preparse('2/3')
'Integer(2)/Integer(3)'
sage: preparse('2./3')
"RealNumber('2.')/Integer(3)"
sage: preparse('x^x')
'x**x'

See also Also, this turns off/on the documentation of preparser:

sage: preparser?
preparser(False)
sage: preparser(True)