# Diamond brackets <> and square brackets [] notations

Are there some documentation on diamond bracket notation:

 R.<w> = PolynomialRing(QQ) 

and square bracket notation:

 R.<y> = QQ['y']; 

There is some documentation in Constructors for polynomial rings docs but it looks superficial on this topic.

Are there some complete explanation with all the details behind the scene?

Is it only for polynomial rings or for some other objects? Is it SageMath addition?

edit retag close merge delete

Sort by » oldest newest most voted

Indeed, this is not 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'


Also, this turns off/on the preparser:

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

more

1

Note that this does not exactly answers the question which started with "Are there some documentation ..."

The relevant documentation is for the function preparse_generators: http://doc.sagemath.org/html/en/refer.... There are more examples (labeled as "TESTS") which are in the code but not the reference manual.

3

Some documentation on that syntax can also be found in the section on A Guided tour on Polynomial of the Tutorial of SageMath at http://doc.sagemath.org/html/en/tutor... But it is true that some clearer documentation on this syntax could be explained on its own chapter somewhere.