ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 28 Apr 2015 14:20:13 -0500Dot-angle syntaxhttp://ask.sagemath.org/question/26665/dot-angle-syntax/ Can somebody give me a hint where this kind of syntax
S.<x> = NumberField(x^2-5)
is defined? I mean the `S.<x>`. It's (relatively) clear from the examples what it does, but I've never seen an a real explanation in the manual.
Thank you.Tue, 28 Apr 2015 02:52:04 -0500http://ask.sagemath.org/question/26665/dot-angle-syntax/Answer by eric_g for <p>Can somebody give me a hint where this kind of syntax</p>
<pre><code>S.<x> = NumberField(x^2-5)
</code></pre>
<p>is defined? I mean the <code>S.<x></code>. It's (relatively) clear from the examples what it does, but I've never seen an a real explanation in the manual.</p>
<p>Thank you.</p>
http://ask.sagemath.org/question/26665/dot-angle-syntax/?answer=26675#post-id-26675Hi,
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](http://www.sagemath.org/doc/reference/repl/sage/repl/preparse.html)
Tue, 28 Apr 2015 14:20:13 -0500http://ask.sagemath.org/question/26665/dot-angle-syntax/?answer=26675#post-id-26675