Posted on • Originally published attech.serhatteker.com on
Python Interactive Shell Interfaces
ThePython Interactive Shell is an interactive interpreter that can executePython commands.
You can invoke it from your default shell —zsh
,bash
,fish
etc.:
$python# or for a specific python version$python3.9
Also you can run interactive shell with a module/file like below:
$python-i somefile.py
Use Case
Thanks python, however I can't say I enjoy your default shell. I need morecapable,colorful interactive shell likeIPython,bpython.
It's easy to achieve this inDjango. It's well documented indjango-shell:
# IPython$django-admin-i ipython# bpython$django-admin-i bpython
Well, how can we achieve it inPython
?
Solution
Python's way is kind of similar; you invoke it with somemodule
using-m
flag:
ForIPython
run:
$python-m IPython-i# with module/file$python-m IPython-i somefile.py
Forbpython
run:
$python-m bpython-i# with module/file$python-m bpython-i somefile.py
NOTE
In order to be able to useIPython and/orbpython first you have to install them:$python-m pipinstallipython$python-m pipinstallbpython
Yes, it's that easy and now we can take advantage of amazing features like below:
- In-line syntax highlighting
- Readline-like auto-complete with suggestions displayed as you type
- Expected parameter list for any Python function, etc.
Probably it would be better to have them as aliases:
# .aliasesaliaspi='python -m IPython -i'aliaspib='python -m bpython -i'
All done!
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse