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.Thu, 13 Jul 2017 10:31:13 -0500How does sagemath modify python?http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/` type(3)
<type 'sage.rings.integer.Integer'>`
So how was sage's python version created, and do I need to learn C to be able to do that ?
I would like some easy to begin guide, on how to achienve the same basic things as I'd like to know it's internal workings. Thu, 13 Jul 2017 04:30:32 -0500http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/Comment by kcrisman for <p><code>type(3)
<type 'sage.rings.integer.Integer'></code></p>
<p>So how was sage's python version created, and do I need to learn C to be able to do that ?
I would like some easy to begin guide, on how to achienve the same basic things as I'd like to know it's internal workings. </p>
http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38232#post-id-38232You definitely don't need to learn C!Thu, 13 Jul 2017 08:29:35 -0500http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38232#post-id-38232Answer by eric_g for <p><code>type(3)
<type 'sage.rings.integer.Integer'></code></p>
<p>So how was sage's python version created, and do I need to learn C to be able to do that ?
I would like some easy to begin guide, on how to achienve the same basic things as I'd like to know it's internal workings. </p>
http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?answer=38229#post-id-38229Sage is indeed preparsing the entries before sending them to Python. To know what Sage is doing exactly with what you are typing, use the command `preparse`, with your Sage command passed as a string:
sage: preparse("3")
'Integer(3)'
sage: preparse("3+2")
'Integer(3)+Integer(2)'
sage: preparse("x^2")
'x**Integer(2)'
Thu, 13 Jul 2017 06:11:29 -0500http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?answer=38229#post-id-38229Comment by John Palmieri for <p>Sage is indeed preparsing the entries before sending them to Python. To know what Sage is doing exactly with what you are typing, use the command <code>preparse</code>, with your Sage command passed as a string:</p>
<pre><code>sage: preparse("3")
'Integer(3)'
sage: preparse("3+2")
'Integer(3)+Integer(2)'
sage: preparse("x^2")
'x**Integer(2)'
</code></pre>
http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38235#post-id-38235See also http://doc.sagemath.org/html/en/tutorial/afterword.html#the-pre-parser-differences-between-sage-and-pythonThu, 13 Jul 2017 10:31:13 -0500http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38235#post-id-38235Comment by kcrisman for <p>Sage is indeed preparsing the entries before sending them to Python. To know what Sage is doing exactly with what you are typing, use the command <code>preparse</code>, with your Sage command passed as a string:</p>
<pre><code>sage: preparse("3")
'Integer(3)'
sage: preparse("3+2")
'Integer(3)+Integer(2)'
sage: preparse("x^2")
'x**Integer(2)'
</code></pre>
http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38233#post-id-38233Yes. And beyond the preparsing and adding lots of functions, there are a few other things that are (slightly) redefined like `sum` which expand their usefulness. For 99% of purposes Sage can be thought of as Python with extra sugar.Thu, 13 Jul 2017 08:30:36 -0500http://ask.sagemath.org/question/38228/how-does-sagemath-modify-python/?comment=38233#post-id-38233