Issue
The --pylab
command line arguments makes ipython
a quick but powerful calculator in the terminal window which I use quite often. Is there a way to pass other useful imports to ipython
via command line, such as
from scipy.constants import *
which makes it even more convenient to use?
Solution
If you have installed sympy
you get script that starts ipython
with sympy
imports. This script may give you ideas.
2119:~/mypy$ which isympy
/usr/local/bin/isympy
2119:~/mypy$ cat /usr/local/bin/isympy
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from isympy import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
There may also be a place in the profile to specify imports, but I haven't explored that recently.
Or use the '-c' option:
2128:~/mypy$ ipython3 --pylab -c "from scipy import constants" -i
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.
Using matplotlib backend: Qt5Agg
In [1]: constants.bar
Out[1]: 100000.0
Answered By - hpaulj
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.