Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Serhat Teker
Serhat Teker

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
Enter fullscreen modeExit fullscreen mode

Also you can run interactive shell with a module/file like below:

$python-i somefile.py
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

Forbpython run:

$python-m bpython-i# with module/file$python-m bpython-i somefile.py
Enter fullscreen modeExit fullscreen mode

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.

bpython-demo-gif

Probably it would be better to have them as aliases:

# .aliasesaliaspi='python -m IPython -i'aliaspib='python -m bpython -i'
Enter fullscreen modeExit fullscreen mode

All done!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Uomo Universale | Software Engineer | Entrepreneur | builds systems | py:go:js |
  • Location
    127.0.0.1
  • Work
    Software Engineer
  • Joined

More fromSerhat Teker

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp