Ask Your Question
3

How to get numbered prompt

asked 2020-04-27 16:30:56 +0100

andro gravatar image

A lot of Ipython docs show numbered prompts like 'In [4]:'. With Sagemath 9 I only have the prompt 'sage:'. How can you set the prompt?

edit retag flag offensive close merge delete

Comments

Why bother ?

FrédéricC gravatar imageFrédéricC ( 2020-04-27 18:59:47 +0100 )edit
1

Because the manual refers to it., and it allows one to easily reuse previous results from back before the underscore references allow. It's a perfectly legitimate question I would have thought.

andro gravatar imageandro ( 2020-04-28 10:26:38 +0100 )edit

1 Answer

Sort by » oldest newest most voted
4

answered 2020-04-27 19:52:50 +0100

tmonteil gravatar image

updated 2020-04-27 23:00:05 +0100

slelievre gravatar image

You can do this :

sage: from IPython.terminal.prompts import Prompts
sage: ip = get_ipython()
sage: ip.prompts = Prompts(ip)
In [4]: 1+1
Out[4]: 2
In [5]: 2+2
Out[5]: 4
In [6]: Out[5]^2
Out[6]: 16

If you want this to be executed each time Sage is started, put these three lines in your init.sage file, which by default is the file ~/.sage/init.sage (create it if it does not exist yet).

edit flag offensive delete link more

Comments

And about customizing the prompt, see my answer to this other post.

vdelecroix gravatar imagevdelecroix ( 2020-05-24 18:49:58 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-27 16:30:56 +0100

Seen: 576 times

Last updated: Apr 27 '20