How to set the default pretty printing behaviour for sage?

47 views
Skip to first unread message

Hongyi Zhao

unread,
May 18, 2021, 1:27:06 AM5/18/21
to sage-support

I want to obtain the similar behavior in sage for pretty printing as in ipython. Any hints will be highly appreciated.

Regards,
HY

Dima Pasechnik

unread,
May 18, 2021, 2:52:04 AM5/18/21
to sage-support
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *


(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)


--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/99bb367f-7564-4736-804c-5d942b1f1773n%40googlegroups.com.

Hongyi Zhao

unread,
May 18, 2021, 5:38:22 AM5/18/21
to sage-support
On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *

Really, it does the trick.



(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)

Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?

Regards,
HY

Dima Pasechnik

unread,
May 18, 2021, 6:31:08 AM5/18/21
to sage-support


On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *

Really, it does the trick.



(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)

Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?

all what sage --ipython does is running a iPython which has sage modules available.

some Sage magic is actually iPython, afaik.

Regards,
HY



On Tue, 18 May 2021, 06:27 Hongyi Zhao, <hongy...@gmail.com> wrote:

I want to obtain the similar behavior in sage for pretty printing as in ipython. Any hints will be highly appreciated.

Regards,
HY

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/99bb367f-7564-4736-804c-5d942b1f1773n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.

Hongyi Zhao

unread,
May 18, 2021, 9:36:08 AM5/18/21
to sage-support
On Tuesday, May 18, 2021 at 6:31:08 PM UTC+8 dim...@gmail.com wrote:


On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *

Really, it does the trick.



(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)

Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?

all what sage --ipython does is running a iPython which has sage modules available.

some Sage magic is actually iPython, afaik.

But, as you have told, not all, say, for power calculation, ^ sign only works in sage.

Dima Pasechnik

unread,
May 18, 2021, 9:53:44 AM5/18/21
to sage-support


On Tue, 18 May 2021, 14:36 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 6:31:08 PM UTC+8 dim...@gmail.com wrote:


On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *

Really, it does the trick.



(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)

Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?

all what sage --ipython does is running a iPython which has sage modules available.

some Sage magic is actually iPython, afaik.

But, as you have told, not all, say, for power calculation, ^ sign only works in sage.

Indeed, that is what I said - you have iPython magic, yes, but not Sage's syntax extensions. (you can still explicitly call Sage's preparser to convert Sage code into Python)
 

Regards,
HY



On Tue, 18 May 2021, 06:27 Hongyi Zhao, <hongy...@gmail.com> wrote:

I want to obtain the similar behavior in sage for pretty printing as in ipython. Any hints will be highly appreciated.

Regards,
HY

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/99bb367f-7564-4736-804c-5d942b1f1773n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.

Hongyi Zhao

unread,
May 19, 2021, 4:53:48 AM5/19/21
to sage-support
On Tuesday, May 18, 2021 at 9:53:44 PM UTC+8 dim...@gmail.com wrote:


On Tue, 18 May 2021, 14:36 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 6:31:08 PM UTC+8 dim...@gmail.com wrote:


On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:


On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
You can just load sage in ipython:

./sage --ipython

and at ipython prompt do

from sage.all import *

Really, it does the trick.



(note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)

Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?

all what sage --ipython does is running a iPython which has sage modules available.

some Sage magic is actually iPython, afaik.

But, as you have told, not all, say, for power calculation, ^ sign only works in sage.

Indeed, that is what I said - you have iPython magic, yes, but not Sage's syntax extensions. (you can still explicitly call Sage's preparser to convert Sage code into Python)

How to do that? What's the exact code/command?

HY

Dima Pasechnik

unread,
May 19, 2021, 4:57:21 AM5/19/21
to sage-support
On Wed, May 19, 2021 at 9:53 AM Hongyi Zhao <hongy...@gmail.com> wrote:
>
>
>
> On Tuesday, May 18, 2021 at 9:53:44 PM UTC+8 dim...@gmail.com wrote:
>>
>>
>>
>> On Tue, 18 May 2021, 14:36 Hongyi Zhao, <hongy...@gmail.com> wrote:
>>>
>>>
>>>
>>> On Tuesday, May 18, 2021 at 6:31:08 PM UTC+8 dim...@gmail.com wrote:
>>>>
>>>>
>>>>
>>>> On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>> On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
>>>>>>
>>>>>> You can just load sage in ipython:
>>>>>>
>>>>>> ./sage --ipython
>>>>>>
>>>>>> and at ipython prompt do
>>>>>>
>>>>>> from sage.all import *
>>>>>
>>>>>
>>>>> Really, it does the trick.
>>>>>
>>>>>>
>>>>>>
>>>>>> (note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)
>>>>>
>>>>>
>>>>> Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?
>>>>
>>>>
>>>> all what sage --ipython does is running a iPython which has sage modules available.
>>>>
>>>> some Sage magic is actually iPython, afaik.
>>>
>>>
>>> But, as you have told, not all, say, for power calculation, ^ sign only works in sage.
>>
>>
>> Indeed, that is what I said - you have iPython magic, yes, but not Sage's syntax extensions. (you can still explicitly call Sage's preparser to convert Sage code into Python)
>
>
> How to do that? What's the exact code/command?
look up docs on

preparse

and

preparser

>
> HY
>
>>>
>>>
>>>>>
>>>>>
>>>>> Regards,
>>>>> HY
>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, 18 May 2021, 06:27 Hongyi Zhao, <hongy...@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>> I want to obtain the similar behavior in sage for pretty printing as in ipython. Any hints will be highly appreciated.
>>>>>>>
>>>>>>> Regards,
>>>>>>> HY
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google Groups "sage-support" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
>>>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/99bb367f-7564-4736-804c-5d942b1f1773n%40googlegroups.com.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups "sage-support" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
>>>>>
>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/7c3b1bad-afd2-4da0-9748-c6c9dc710204n%40googlegroups.com.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "sage-support" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/8db460ee-9c2c-449f-97c9-e13695a82dc3n%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/9f932177-4e50-4045-9439-5e3fa681d2c7n%40googlegroups.com.

Hongyi Zhao

unread,
May 19, 2021, 5:22:41 AM5/19/21
to sage-support
On Wednesday, May 19, 2021 at 4:57:21 PM UTC+8 dim...@gmail.com wrote:
On Wed, May 19, 2021 at 9:53 AM Hongyi Zhao <hongy...@gmail.com> wrote:
>
>
>
> On Tuesday, May 18, 2021 at 9:53:44 PM UTC+8 dim...@gmail.com wrote:
>>
>>
>>
>> On Tue, 18 May 2021, 14:36 Hongyi Zhao, <hongy...@gmail.com> wrote:
>>>
>>>
>>>
>>> On Tuesday, May 18, 2021 at 6:31:08 PM UTC+8 dim...@gmail.com wrote:
>>>>
>>>>
>>>>
>>>> On Tue, 18 May 2021, 10:38 Hongyi Zhao, <hongy...@gmail.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>> On Tuesday, May 18, 2021 at 2:52:04 PM UTC+8 dim...@gmail.com wrote:
>>>>>>
>>>>>> You can just load sage in ipython:
>>>>>>
>>>>>> ./sage --ipython
>>>>>>
>>>>>> and at ipython prompt do
>>>>>>
>>>>>> from sage.all import *
>>>>>
>>>>>
>>>>> Really, it does the trick.
>>>>>
>>>>>>
>>>>>>
>>>>>> (note this does not load sage's preparser, i.e. you won't be able to use ^ instead of **, etc)
>>>>>
>>>>>
>>>>> Thank you. When using the `--ipython` option to call sage, can I still have the magical function of the sage at the same time?
>>>>
>>>>
>>>> all what sage --ipython does is running a iPython which has sage modules available.
>>>>
>>>> some Sage magic is actually iPython, afaik.
>>>
>>>
>>> But, as you have told, not all, say, for power calculation, ^ sign only works in sage.
>>
>>
>> Indeed, that is what I said - you have iPython magic, yes, but not Sage's syntax extensions. (you can still explicitly call Sage's preparser to convert Sage code into Python)
>
>
> How to do that? What's the exact code/command?
look up docs on

preparse

and

preparser


Thank you for your hints. I find the pertinent documentation here: <https://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html>.

Regards,
HY
Reply all
Reply to author
Forward
0 new messages