本文整理汇总了Python中IPython.terminal.embed.InteractiveShellEmbed.interface方法的典型用法代码示例。如果您正苦于以下问题:Python InteractiveShellEmbed.interface方法的具体用法?Python InteractiveShellEmbed.interface怎么用?Python InteractiveShellEmbed.interface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.terminal.embed.InteractiveShellEmbed
的用法示例。
在下文中一共展示了InteractiveShellEmbed.interface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interface_shell_embed
# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import interface [as 别名]
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 ]
<IPython.core.interactiveshell.ExecutionResult object at 0x...>
"""
try:
cfg = copy.deepcopy(get_ipython().config)
except NameError:
cfg = copy.deepcopy(DEFAULT_SAGE_CONFIG)
cfg.PromptManager['in_template'] = interface.name() + ': '
cfg.PromptManager['in2_template'] = len(interface.name())*'.' + ': '
ipshell = InteractiveShellEmbed(config=cfg,
banner1='\n --> Switching to %s <--\n\n'%interface,
exit_msg = '\n --> Exiting back to Sage <--\n')
ipshell.interface = interface
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
示例2: interface_shell_embed
# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import interface [as 别名]
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
示例3: interface_shell_embed
# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import interface [as 别名]
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