IPython
- IPython - Introduction
- IPython - Installation
- IPython - Getting Started
- Running & Editing Python Script
- IPython - History Command
- IPython - System Commands
- IPython - Command Line Options
- Dynamic Object Introspection
- IPython - IO Caching
- Setting IPython as Default Python Environment
- Importing Python Shell Code
- IPython - Embedding IPython
- IPython - Magic Commands
Jupyter
- Project Jupyter - Overview
- Jupyter Notebook - Introduction
- Working With Jupyter Online
- Installation and Getting Started
- Jupyter Notebook - Dashboard
- Jupyter Notebook - User Interface
- Jupyter Notebook - Types of Cells
- Jupyter Notebook - Editing
- Jupyter Notebook - Markdown Cells
- Cell Magic Functions
- Jupyter Notebook - Plotting
- Converting Notebooks
- Jupyter Notebook - IPyWidgets
QtConsole
- QtConsole - Getting Started
- QtConsole - Multiline Editing
- QtConsole - Inline Graphics
- QtConsole - Save to Html
- QtConsole - Multiple Consoles
- Connecting to Jupyter Notebook
- Using github and nbviewer
JupyterLab
- JupyterLab - Overview
- Installation & Getting Started
- JupyterLab - Interface
- JupyterLab - Installing R Kernel
Jupyter Resources
IPython - Running and Editing Python Script
In this chapter, let us understand how to run and edit a Python script.
We are using following python script as main.py
print("Hello IPython")
Run Command
You can use run command in the input prompt to run a Python script. The run command is actually line magic command and should actually be written as %run. However, the %automagic mode is always on by default, so you can omit this.
In [1]: run main.py Hello IPython
Edit Command
IPython also provides edit magic command. It invokes default editor of the operating system. You can open it through Windows Notepad editor and the script can be edited. Once you close it after saving its input, the output of modified script will be displayed.
In [2]: edit hello.py Editing... done. Executing edited code... Hello IPython welcome to interactive computing
Note that main.py initially contained only one statement and after editing one more statement was added.
print("Hello IPython")
print("welcome to interactive computing")
If no file name is given to edit command, a temporary file is created. Observe the following code that shows the same.
In [9]: edit
IPython will make a temporary file named: C:\Users\mahes\AppData\Local\Temp\ipython_edit_azsaqifq\ipython_edit_z0t4ok9i.py
Editing... done. Executing edited code...
magic of IPython
Out[9]: 'print ("magic of IPython")'