def interface_shell_embed(interface): """ Returns an IPython shell which uses a Sage interface on the backend to perform the evaluations. It uses :class:`InterfaceShellTransformer` to transform the input into the appropriate ``interface.eval(...)`` input. INPUT: - ``interface`` -- A Sage ``PExpect`` interface instance. EXAMPLES:: sage: from sage.repl.interpreter import interface_shell_embed sage: shell = interface_shell_embed(gap) sage: shell.run_cell('List( [1..10], IsPrime )') [ false, true, true, false, true, false, true, false, false, false ] <repr(<IPython.core.interactiveshell.ExecutionResult at 0x...>) failed: AttributeError: type object 'ExecutionResult' has no attribute '__qualname__'> Note that the repr error is https://github.com/ipython/ipython/issues/9756 """ cfg = sage_ipython_config.copy() ipshell = InteractiveShellEmbed(config=cfg, banner1='\n --> Switching to %s <--\n\n'%interface, exit_msg='\n --> Exiting back to Sage <--\n') ipshell.interface = interface ipshell.prompts = InterfacePrompts(interface.name()) while ipshell.prefilter_manager.transformers: ipshell.prefilter_manager.transformers.pop() while ipshell.prefilter_manager.checkers: ipshell.prefilter_manager.checkers.pop() ipshell.ex('import sage.misc.all') InterfaceShellTransformer(shell=ipshell, prefilter_manager=ipshell.prefilter_manager, config=cfg) return ipshell
def interface_shell_embed(interface): """ Returns an IPython shell which uses a Sage interface on the backend to perform the evaluations. It uses :class:`InterfaceShellTransformer` to transform the input into the appropriate ``interface.eval(...)`` input. INPUT: - ``interface`` -- A Sage ``PExpect`` interface instance. EXAMPLES:: sage: from sage.repl.interpreter import interface_shell_embed sage: shell = interface_shell_embed(gap) sage: shell.run_cell('List( [1..10], IsPrime )') [ false, true, true, false, true, false, true, false, false, false ] <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None result=[ false, true, true, false, true, false, true, false, false, false ]> """ cfg = sage_ipython_config.copy() ipshell = InteractiveShellEmbed( config=cfg, banner1='\n --> Switching to %s <--\n\n' % interface, exit_msg='\n --> Exiting back to Sage <--\n') ipshell.interface = interface ipshell.prompts = InterfacePrompts(interface.name()) while ipshell.prefilter_manager.transformers: ipshell.prefilter_manager.transformers.pop() while ipshell.prefilter_manager.checkers: ipshell.prefilter_manager.checkers.pop() ipshell.ex('import sage.misc.all') InterfaceShellTransformer(shell=ipshell, prefilter_manager=ipshell.prefilter_manager, config=cfg) return ipshell
def interface_shell_embed(interface): """ Returns an IPython shell which uses a Sage interface on the backend to perform the evaluations. It uses :class:`InterfaceShellTransformer` to transform the input into the appropriate ``interface.eval(...)`` input. INPUT: - ``interface`` -- A Sage ``PExpect`` interface instance. EXAMPLES:: sage: from sage.repl.interpreter import interface_shell_embed sage: shell = interface_shell_embed(gap) sage: shell.run_cell('List( [1..10], IsPrime )') [ false, true, true, false, true, false, true, false, false, false ] <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None result=[ false, true, true, false, true, false, true, false, false, false ]> """ cfg = sage_ipython_config.copy() ipshell = InteractiveShellEmbed(config=cfg, banner1='\n --> Switching to %s <--\n\n'%interface, exit_msg='\n --> Exiting back to Sage <--\n') ipshell.interface = interface ipshell.prompts = InterfacePrompts(interface.name()) while ipshell.prefilter_manager.transformers: ipshell.prefilter_manager.transformers.pop() while ipshell.prefilter_manager.checkers: ipshell.prefilter_manager.checkers.pop() ipshell.ex('import sage.misc.all') InterfaceShellTransformer(shell=ipshell, prefilter_manager=ipshell.prefilter_manager, config=cfg) return ipshell