本文整理汇总了Python中IPython.terminal.interactiveshell.TerminalInteractiveShell.raw_input方法的典型用法代码示例。如果您正苦于以下问题:Python TerminalInteractiveShell.raw_input方法的具体用法?Python TerminalInteractiveShell.raw_input怎么用?Python TerminalInteractiveShell.raw_input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.terminal.interactiveshell.TerminalInteractiveShell
的用法示例。
在下文中一共展示了TerminalInteractiveShell.raw_input方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: raw_input
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import raw_input [as 别名]
def raw_input(self, *args, **kw):
try:
return TerminalInteractiveShell.raw_input(self,
*args, **kw) # needs decoding (see below)?
except EOFError:
r = raw_input("Do you wish to commit your "
"database changes? [yes]")
if not r.lower().startswith("n"):
if using_sqlalchemy:
self.push("session.flush()")
else:
self.push("hub.commit()")
raise EOFError
示例2: get_python_console
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import raw_input [as 别名]
def get_python_console(namespace=None):
"""
Return a interactive python console instance with caller's stack
"""
if namespace is None:
import inspect
frame = inspect.currentframe()
caller = frame.f_back
if not caller:
logging.error("can't find caller who start this console.")
caller = frame
namespace = dict(caller.f_globals)
namespace.update(caller.f_locals)
try:
from IPython.terminal.interactiveshell import TerminalInteractiveShell
shell = TerminalInteractiveShell(user_ns=namespace)
except ImportError:
try:
import readline
import rlcompleter
readline.set_completer(rlcompleter.Completer(namespace).complete)
readline.parse_and_bind("tab: complete")
except ImportError:
pass
import code
shell = code.InteractiveConsole(namespace)
shell._quit = False
def exit():
shell._quit = True
def readfunc(prompt=""):
if shell._quit:
raise EOFError
return six.moves.input(prompt)
# inject exit method
shell.ask_exit = exit
shell.raw_input = readfunc
return shell
示例3: raw_input
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import raw_input [as 别名]
def raw_input(self, prompt=""):
# TODO correct eof issue with custom prompt.
prompt = "iridium >>>"
return TerminalInteractiveShell.raw_input(self, prompt)