Debian Codegraph @

examples/Embedding/start_ipython_config.py

raw
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)