Linux, OpenSource, Programming And Hacks

Mar 24, 2018

Ipython, an alternative Interactive Python interpreter [tutorial]

Mar 24, 2018

Ipython is an interactive python shell which can be used as a replacement for your default python interpreter.

Install Ipython

pip install Ipython

Launch Ipython

Just enter ipython in your terminal

aman@vostro:~$ ipython
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

Features & Usage

1. Tab Completion

example: Suppose you are typing out the print statement, you can just type 'pri' and hit tab that will auto complete it.

2. Navigate to Previous command

use the up arrow key to get the previous entered command. This is very useful in the case of block of codes like if ,for, def. The whole block will reappear on pressing the up arrow key. in the default python shell only one statement appears at a time.

3. Details about any object

In [1]: print?
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file:  a file-like object (stream); defaults to the current sys.stdout.
sep:   string inserted between values, default a space.
end:   string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Type:      builtin_function_or_method
In [2]: abs?
Signature: abs(x, /)
Docstring: Return the absolute value of the argument.
Type:      builtin_function_or_method

Quit Ipython

ctrl + d

No comments:

Post a Comment