5 ms·
Deep research uses aside, I often prefer to use IPython because it's simply a better shell than the default Python shell. You get basic niceties like tab comple
by AdmiralAsshat 8y ago
Deep research uses aside, I often prefer to use IPython because it's simply a better shell than the default Python shell. You get basic niceties like tab completion and being able to up-arrow to revise an earlier multi-line command (like a function) without it being an exercise in frustration.
- deleted 8y ago[deleted]
- Bromskloss 8y agoIndeed. If I could only figure out how to have it automatically run `from math import *` (and then present me with the interactive shell, I could use it as a calculator too.
- spot 8y agohttp://ipython.readthedocs.io/en/stable/config/options/terminal.html#configtrait-InteractiveShellApp.exec_lines http://ipython.readthedocs.io/en/stable/config/options/termi...
- Bromskloss 8y agoMy problem is that I don't know how to make it accept spaces in the command to be run. This works: ipython3 --InteractiveShellApp.exec_lines='["print(2)"]' This does not work: ipython3 --InteractiveShellApp.exec_lines='["from math import *"]' The latter command results in the following error: [TerminalIPythonApp] CRITICAL | The 'exec_lines' trait of a TerminalIPythonApp instance must be a list, but a value of class 'str' (i.e. '["from') was specified.
- takluyver 8y agoRather than fiddling around with quoting bash, you can put the import line in a startup file: http://ipython.readthedocs.io/en/stable/interactive/tutorial.html#startup-files http://ipython.readthedocs.io/en/stable/interactive/tutorial...
- spot 8y agoidk, it works for me: $ ipython3 --InteractiveShellApp.exec_lines='["from math import *"]' Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) Type 'copyright', 'credits' or 'license' for more information IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: sin(5) Out[1]: -0.9589242746631385
- Bromskloss 8y agoI see. I have iPython 5.1.0. Maybe there was a bug that has been fixed in yours.
- UnquietTinkerer 8y agoTry this shell script: #! /bin/sh # This is a bit hacky: we use the -i flag to force the interpreter into # interactive mode after the initial commands are executed. # The "proper" way to do this is probably to set up a PYTHONSTARTUP file # and put the initial commands in there. exec ipython3 --no-banner --no-confirm-exit -i -c ' from math import * import random import sys, os, platform print("== IPython %s Calculator REPL ==" % platform.python_version()) '
- Bromskloss 8y agoThank you for the suggestion! I still get the error, unfortunately: File "<ipython-input-1-a0531db54fa8>", line 1 from ^ SyntaxError: invalid syntax I shall see if it starts working when I upgrade to a distro with a newer IPython.
- Something1234 8y agoThe multiline history is so important for an interactive shell with a language that considers indentation important.