8 Defines a function embed() that can be used to drop into an interactive python
9 shell from within a steering file or python module. If available, IPython will
10 be used. Use Ctrl+D to exit the shell.
12 >>> import interactive
13 >>> interactive.embed()
16 See framework/examples/interactive.py for an example.
19 from IPython
import embed
20 from traitlets.config.loader
import Config
21 from IPython.terminal.prompts
import Prompts, Token
25 """Provide slightly customized prompts when running basf2 interactively"""
29 return [(Token.Prompt,
"basf2 in ["),
30 (Token.PromptNum, str(self.shell.execution_count)),
31 (Token.Prompt,
']: ')]
35 return [(Token.OutPrompt,
"basf2 out["),
36 (Token.OutPromptNum, str(self.shell.execution_count)),
37 (Token.OutPrompt,
']: ')]
40 def basf2_shell_config():
41 """Return a config object customizing the shell prompt for basf2"""
43 c.TerminalInteractiveShell.prompts_class = Basf2IPythonPrompt