Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the IPython prompt number for?

Tags:

ipython

I'm using IPython web notebook and there's a prompt number before each block such as "In [68]:". What's the purpose of this prompt number? Can you do anything with it? Can/should you ever reset it?

like image 395
Ben McCann Avatar asked Feb 15 '12 05:02

Ben McCann


1 Answers

IPython caches inputs and outputs, so you can reference and reuse the input or output of each cell. The prompt numbers correspond to the indices for accessing these objects.

So you can do things like:

a = Out[5]

to reuse the output of a cell.

See the relevant docs for details.

The prompt count will be reset if/when you restart the kernel, because these caches will no longer exist.

like image 106
minrk Avatar answered Oct 14 '22 21:10

minrk