4 ms·
Python's REPL has autocompletion. It is just not enabled by default as it lives in its own module and python prefers to start in an absolutely clean state.
by lloeki 16y ago
Python's REPL has autocompletion. It is just not enabled by default as it lives in its own module and python prefers to start in an absolutely clean state.
>>> import readline
>>> import rlcompleter
>>> readline.parse_and_bind('tab: complete')
See this article for the details (and more, like history persistence and REPL startup file): http://valueerror.wordpress.com/2009/11/03/python-shell-history-autocompletion-and-rc-file/ http://valueerror.wordpress.com/2009/11/03/python-shell-hist...
- StavrosK 16y agoWho doesn't use ipython these days, though?
- j4mie 16y agoI use bpython: http://bpython-interpreter.org/ http://bpython-interpreter.org/
- StavrosK 16y agoAlso excellent.
- dagw 16y agoPeople who use DreamPie (http://dreampie.sourceforge.net http://dreampie.sourceforge.net)
- arctangent 16y agoI've read about it but never used it - I write all my code in TextMate, Notepad++ or Nano, depending on where I am and what I'm doing. Could you outline what you see are the main benefits of using an enhanced interactive interface to Python such as IPython?
- lloeki 16y agoIt actually makes python a full-blown shell (which python REPL is not): $ ipython Leopard libedit detected. Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) Type "copyright", "credits" or "license" for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: ls Applications/ Downloads/ Movies/ Public/ Workspace/ Desktop/ Dropbox/ Music/ Sandbox/ Documents/ Library/ Pictures/ Sites/ In [2]: ls | grep App Applications/ In [3]:
- StavrosK 16y agoThe advantages of using a REPL versus just coding is that you can test some things out before writing the code. To be honest, I don't use it much while programming, but it's indispensable for doing some Django queries or for playing with live code (you can run it in the shell and break to inspect the stack). Its advantage over the stock Python repl is that it has better code completion, colours, pretty printing, nice history, built-in profiling and many other niceties I enjoy.