IPython
- IPython - Magic Commands
- IPython - Embedding IPython
- Importing Python Shell Code
- Setting IPython as Default Python Environment
- IPython - IO Caching
- Dynamic Object Introspection
- IPython - Command Line Options
- IPython - System Commands
- IPython - History Command
- Running & Editing Python Script
- IPython - Getting Started
- IPython - Installation
- IPython - Introduction
Jupyter
- Jupyter Notebook - IPyWidgets
- Converting Notebooks
- Jupyter Notebook - Plotting
- Cell Magic Functions
- Jupyter Notebook - Markdown Cells
- Jupyter Notebook - Editing
- Jupyter Notebook - Types of Cells
- Jupyter Notebook - User Interface
- Jupyter Notebook - Dashboard
- Installation and Getting Started
- Working With Jupyter Online
- Jupyter Notebook - Introduction
- Project Jupyter - Overview
QtConsole
- Using github and nbviewer
- Connecting to Jupyter Notebook
- QtConsole - Multiple Consoles
- QtConsole - Save to Html
- QtConsole - Inline Graphics
- QtConsole - Multiline Editing
- QtConsole - Getting Started
JupyterLab
- JupyterLab - Installing R Kernel
- JupyterLab - Interface
- Installation & Getting Started
- JupyterLab - Overview
Jupyter Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
IPython - IO Caching
The input and output cells on IPython console are numbered incrementally. In this chapter, let us look into IO caching in Python in detail.
In IPython, inputs are retrieved using up arrow key. Besides, all previous inputs are saved and can be retrieved. The variables _i, __i, and ___i always store the previous three input entries. In addition, In and _in variables provides psts of all inputs. Obviously _in[n] retrieves input from nth input cell. The following IPython session helps you to understand this phenomenon −
In [1]: print ("Hello") Hello In [2]: 2+2 Out[2]: 4 In [3]: x = 10 In [4]: y = 2 In [5]: pow(x,y) Out[5]: 100 In [6]: _iii, _ii, _i Out[6]: ( x = 10 , y = 2 , pow(x,y) ) In [7]: In Out[7]: [ , print ("Hello") , 2+2 , x = 10 , y = 2 , pow(x,y) , _iii, _ii, _i , In ] In [8]: In[5] 9. IPython — IO Out[8]: pow(x,y) In [9]: _ih Out[9]: [ , print ("Hello") , 2+2 , x = 10 , y = 2 , pow(x,y) , _iii, _ii, _i , In , In[5] , _ih ] In [11]: _ih[4] Out[11]: y = 2 In [12]: In[1:4] Out[12]: [ print ("Hello") , 2+2 , x=10 ]
Similarly, single, double and triple underscores act as variables to store previous three outputs. Also Out and _oh form a dictionary object of cell number and output of cells performing action (not including assignment statements). To retrieve contents of specific output cell, use Out[n] or _oh[n]. You can also use spcing to get output cells within a range.
In [1]: print ("Hello") Hello In [2]: 2+2 Out[2]: 4 In [3]: x = 10 In [4]: y = 3 In [5]: pow(x,y) Out[5]: 1000 In [6]: ___, __, _ Out[6]: ( , 4, 1000) In [7]: Out Out[7]: {2: 4, 5: 1000, 6: ( , 4, 1000)} In [8]: _oh Out[8]: {2: 4, 5: 1000, 6: ( , 4, 1000)} In [9]: _5 Out[9]: 1000 In [10]: Out[6] Out[10]: ( , 4, 1000)Advertisements