# 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7995756,"math_prob":0.57788444,"size":452,"snap":"2021-21-2021-25","text_gpt3_token_len":92,"char_repetition_ratio":0.14508928,"word_repetition_ratio":0.0,"special_character_ratio":0.2079646,"punctuation_ratio":0.11392405,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9700611,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-09T14:14:25Z\",\"WARC-Record-ID\":\"<urn:uuid:02acaae8-4178-4684-9d84-41dbe38f08c2>\",\"Content-Length\":\"59782\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e4b77c5a-1fea-42f7-bbf0-70f79b0de3d0>\",\"WARC-Concurrent-To\":\"<urn:uuid:b4e03394-b536-41f8-95c6-1961739bf5a3>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/50560/diamond-brackets-and-square-brackets-notations/?answer=50561\",\"WARC-Payload-Digest\":\"sha1:R7DDY4FAZSEKU6VQGTPBV3W3KV6DTWYE\",\"WARC-Block-Digest\":\"sha1:LCABCIIQM5VHTDY6ZZSJBUWHRA6LXLJV\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243988986.98_warc_CC-MAIN-20210509122756-20210509152756-00586.warc.gz\"}"}