From 2563ff8facbc2bac29500f5e49b4d41517fbc77a 2017-08-01 19:20:40 From: Erich Spaker Date: 2017-08-01 19:20:40 Subject: [PATCH] added example of configuring and embedded interpreter --- diff --git a/examples/Embedding/embed_configured.py b/examples/Embedding/embed_configured.py new file mode 100755 index 0000000..86be1a5 --- /dev/null +++ b/examples/Embedding/embed_configured.py @@ -0,0 +1,22 @@ +"""Quick snippet explaining how to set config options when embedding ipython.""" + +# First create a config object from the traitlets library +from traitlets.config import Config +c = Config() + +# Now we can set options as we would in a config file: +# c.Class.config_value = value +# For, example, we can set the exec_lines option of the InteractiveShellApp +# class to run some code when the IPython REPL starts +c.InteractiveShellApp.exec_lines = [ + 'print("\\nimporting some things\\n")', + 'import math', + "math" +] +c.InteractiveShell.colors = 'LightBG' +c.InteractiveShell.confirm_exit = False +c.TerminalIPythonApp.display_banner = False + +# Now we start ipython with our configurtion +import IPython +IPython.start_ipython(config=c)