##// END OF EJS Templates
Merge pull request #10727 from blueForestIcarus/master...
Thomas Kluyver -
r23830:268a3774 merge
parent child Browse files
Show More
@@ -0,0 +1,22 b''
1 """Quick snippet explaining how to set config options when using start_ipython."""
2
3 # First create a config object from the traitlets library
4 from traitlets.config import Config
5 c = Config()
6
7 # Now we can set options as we would in a config file:
8 # c.Class.config_value = value
9 # For example, we can set the exec_lines option of the InteractiveShellApp
10 # class to run some code when the IPython REPL starts
11 c.InteractiveShellApp.exec_lines = [
12 'print("\\nimporting some things\\n")',
13 'import math',
14 "math"
15 ]
16 c.InteractiveShell.colors = 'LightBG'
17 c.InteractiveShell.confirm_exit = False
18 c.TerminalIPythonApp.display_banner = False
19
20 # Now we start ipython with our configuration
21 import IPython
22 IPython.start_ipython(config=c)
@@ -112,6 +112,19 b' At present, this only affects the current session - changes you make to'
112 config are not saved anywhere. Also, some options are only read when
112 config are not saved anywhere. Also, some options are only read when
113 IPython starts, so they can't be changed like this.
113 IPython starts, so they can't be changed like this.
114
114
115 .. _configure_start_ipython:
116
117 Running IPython from Python
118 ----------------------------
119
120 If you are using :ref:`embedding` to start IPython from a normal
121 python file, you can set configuration options the same way as in a
122 config file by creating a traitlets config object and passing it to
123 start_ipython like in the example below.
124
125 .. literalinclude:: ../../../examples/Embedding/start_ipython_config.py
126 :language: python
127
115 .. _profiles:
128 .. _profiles:
116
129
117 Profiles
130 Profiles
@@ -604,6 +604,8 b' You can start a regular IPython session with'
604
604
605 at any point in your program. This will load IPython configuration,
605 at any point in your program. This will load IPython configuration,
606 startup files, and everything, just as if it were a normal IPython session.
606 startup files, and everything, just as if it were a normal IPython session.
607 For information on setting configuration options when running IPython from
608 python, see :ref:`configure_start_ipython`.
607
609
608 It is also possible to embed an IPython shell in a namespace in your Python code.
610 It is also possible to embed an IPython shell in a namespace in your Python code.
609 This allows you to evaluate dynamically the state of your code,
611 This allows you to evaluate dynamically the state of your code,
General Comments 0
You need to be logged in to leave comments. Login now