3 """Python shell for SymPy.
5 This is just a normal Python shell (IPython shell if you have the
6 IPython package installed), that executes the following commands
9 >>> from __future__ import division
10 >>> from sympy import *
11 >>> x, y, z = symbols("xyz")
12 >>> k, m, n = symbols("kmn", integer=True)
13 >>> f, g, h = map(Function, 'fgh')
15 So starting 'isympy' is equivalent to starting Python (or IPython)
16 and executing the above commands by hand. It is intended for easy
17 and quick experimentation with SymPy.
22 -c CONSOLE, --console=CONSOLE
24 Use the specified Python or IPython shell as console backend instead
25 of the default one (IPython if present or Python otherwise), e.g.:
29 -p PRETTY, --pretty PRETTY
31 Setup pretty printing in SymPy. By default the most pretty, Unicode
32 printing is enabled. User can use less pretty ASCII printing instead
33 or no pretty printing at all, e.g.:
37 Print only Python's and SymPy's versions to stdout at startup.
41 Additionally you can pass command line options directly to IPython
42 interpreter (standard Python shell is not supported). However you
43 need to add '--' separator between two types of options. To run
44 SymPy without startup banner and colors, for example, issue:
46 isympy -q -- -colors NoColor
52 # hook in-tree SymPy into Python path, if possible
54 isympy_dir
= os
.path
.dirname(__file__
) # bin/isympy
55 sympy_top
= os
.path
.split(isympy_dir
)[0] # ../
56 sympy_dir
= os
.path
.join(sympy_top
, 'sympy') # ../sympy/
58 if os
.path
.isdir(sympy_dir
):
59 sys
.path
.insert(0, sympy_top
)
61 # some longer messages
64 These commands were executed:
65 >>> from __future__ import division
66 >>> from sympy import *
67 >>> x, y, z = symbols('xyz')
68 >>> k, m, n = symbols('kmn', integer=True)
69 >>> f, g, h = map(Function, 'fgh')
71 Documentation can be found at http://sympy.org/
75 Couldn't locate IPython. Having IPython installed is greatly recommended.
76 See http://ipython.scipy.org for more details. If you use Debian/Ubuntu,
77 just install the 'ipython' package and start isympy again.
80 from sympy
.interactive
import init_session
83 from sympy
import __version__
as sympy_version
84 py_version
= "%d.%d.%d" % sys
.version_info
[:3]
86 from optparse
import OptionParser
88 usage
= 'usage: isympy [options] -- [ipython options]'
89 parser
= OptionParser(usage
, version
=sympy_version
)
96 help='select type of interactive session: IPython | Python')
103 help='setup pretty printing: Unicode | ASCII | any | no')
110 help='print only version information at startup')
112 (options
, ipy_args
) = parser
.parse_args()
114 session
= options
.console
116 if session
is not None:
117 session
= session
.lower()
122 'use_unicode' : None,
125 pretty
= options
.pretty
.lower()
128 if pretty
== 'unicode':
129 args
['use_unicode'] = True
131 args
['use_unicode'] = False
133 if pretty
!= 'ascii':
135 args
['pretty'] = False
137 raise ValueError("Unknown pretty" \
138 " printing setup: " + options
.pretty
)
140 if not options
.quiet
:
141 args
['message'] = long_message
144 init_session(session
, **args
)
147 init_session('ipython', **args
)
150 init_session('python', **args
)
152 if __name__
== "__main__":