當前位置: 首頁>>代碼示例>>Python>>正文


Python TerminalInteractiveShell.instance方法代碼示例

本文整理匯總了Python中IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell.instance方法的典型用法代碼示例。如果您正苦於以下問題:Python TerminalInteractiveShell.instance方法的具體用法?Python TerminalInteractiveShell.instance怎麽用?Python TerminalInteractiveShell.instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell的用法示例。


在下文中一共展示了TerminalInteractiveShell.instance方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_ipython_shell_v11

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
def run_ipython_shell_v11(locals, globals, first_time):
    '''IPython shell from IPython version 0.11'''
    if first_time:
        banner = "Hit Ctrl-D to return to PuDB."
    else:
        banner = ""

    from IPython.frontend.terminal.interactiveshell import \
            TerminalInteractiveShell
    from IPython.frontend.terminal.ipapp import load_default_config
    # XXX: in the future it could be useful to load a 'pudb' config for the
    # user (if it exists) that could contain the user's macros and other
    # niceities.
    config = load_default_config()
    shell = TerminalInteractiveShell.instance(config=config,
            banner2=banner)
    # XXX This avoids a warning about not having unique session/line numbers.
    # See the HistoryManager.writeout_cache method in IPython.core.history.
    shell.history_manager.new_session()
    # Save the originating namespace
    old_locals = shell.user_ns
    old_globals = shell.user_global_ns
    # Update shell with current namespace
    _update_ns(shell, locals, globals)
    shell.mainloop(banner)
    # Restore originating namespace
    _update_ns(shell, old_locals, old_globals)
開發者ID:AntoineD,項目名稱:pudb,代碼行數:29,代碼來源:shell.py

示例2: construct

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
    def construct(self):
        # I am a little hesitant to put these into InteractiveShell itself.
        # But that might be the place for them
        sys.path.insert(0, '')

        # Create an InteractiveShell instance.
        self.shell = TerminalInteractiveShell.instance(config=self.master_config)
開發者ID:08saikiranreddy,項目名稱:ipython,代碼行數:9,代碼來源:ipapp.py

示例3: start_ipython

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
def start_ipython():
    """Start a global IPython shell, which we need for IPython-specific syntax.
    """
    global get_ipython

    # This function should only ever run once!
    if hasattr(start_ipython, 'already_called'):
        return
    start_ipython.already_called = True
    
    # Store certain global objects that IPython modifies
    _displayhook = sys.displayhook
    _excepthook = sys.excepthook
    _main = sys.modules.get('__main__')

    # Create custom argv and namespaces for our IPython to be test-friendly
    config = tools.default_config()

    # Create and initialize our test-friendly IPython instance.
    shell = TerminalInteractiveShell.instance(config=config, 
                                              user_ns=ipnsdict(),
                                              user_global_ns={}
                                              )

    # A few more tweaks needed for playing nicely with doctests...
    
    # These traps are normally only active for interactive use, set them
    # permanently since we'll be mocking interactive sessions.
    shell.builtin_trap.activate()

    # Modify the IPython system call with one that uses getoutput, so that we
    # can capture subcommands and print them to Python's stdout, otherwise the
    # doctest machinery would miss them.
    shell.system = MethodType(xsys, shell, TerminalInteractiveShell)
                       

    shell._showtraceback = MethodType(_showtraceback, shell,
                                      TerminalInteractiveShell)

    # IPython is ready, now clean up some global state...
    
    # Deactivate the various python system hooks added by ipython for
    # interactive convenience so we don't confuse the doctest system
    sys.modules['__main__'] = _main
    sys.displayhook = _displayhook
    sys.excepthook = _excepthook

    # So that ipython magics and aliases can be doctested (they work by making
    # a call into a global _ip object).  Also make the top-level get_ipython
    # now return this without recursively calling here again.
    _ip = shell
    get_ipython = _ip.get_ipython
    __builtin__._ip = _ip
    __builtin__.get_ipython = get_ipython
    
    # To avoid extra IPython messages during testing, suppress io.stdout/stderr
    io.stdout = StreamProxy('stdout')
    io.stderr = StreamProxy('stderr')

    return _ip
開發者ID:BlackgateResearch,項目名稱:gmr_django,代碼行數:62,代碼來源:globalipapp.py

示例4: init_shell

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
 def init_shell(self):
     """initialize the InteractiveShell instance"""
     # Create an InteractiveShell instance.
     # shell.display_banner should always be False for the terminal
     # based app, because we call shell.show_banner() by hand below
     # so the banner shows *before* all extension loading stuff.
     self.shell = TerminalInteractiveShell.instance(
         config=self.config, display_banner=False, profile_dir=self.profile_dir, ipython_dir=self.ipython_dir
     )
     self.shell.configurables.append(self)
開發者ID:fccoelho,項目名稱:ipython,代碼行數:12,代碼來源:ipapp.py

示例5: init_shell

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
    def init_shell(self):
        """initialize the InteractiveShell instance"""
        # I am a little hesitant to put these into InteractiveShell itself.
        # But that might be the place for them
        sys.path.insert(0, '')

        # Create an InteractiveShell instance.
        # shell.display_banner should always be False for the terminal 
        # based app, because we call shell.show_banner() by hand below
        # so the banner shows *before* all extension loading stuff.
        self.shell = TerminalInteractiveShell.instance(config=self.config,
                        display_banner=False, profile_dir=self.profile_dir,
                        ipython_dir=self.ipython_dir)
開發者ID:grahame,項目名稱:ipython-py3k,代碼行數:15,代碼來源:ipapp.py

示例6: __init__

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
    def __init__(self, *args, **kwargs):        
        # Initialization based on: from IPython.testing.globalipapp import start_ipython
        
        self._curr_exec_line = 0
        # Store certain global objects that IPython modifies
        _displayhook = sys.displayhook
        _excepthook = sys.excepthook
    
        # Create and initialize our IPython instance.
        shell = TerminalInteractiveShell.instance()
        # Create an intput splitter to handle input separation
        self.input_splitter = IPythonInputSplitter()

        shell.showtraceback = _showtraceback
        # IPython is ready, now clean up some global state...
        
        # Deactivate the various python system hooks added by ipython for
        # interactive convenience so we don't confuse the doctest system
        sys.displayhook = _displayhook
        sys.excepthook = _excepthook
    
        # So that ipython magics and aliases can be doctested (they work by making
        # a call into a global _ip object).  Also make the top-level get_ipython
        # now return this without recursively calling here again.
        get_ipython = shell.get_ipython
        try:
            import __builtin__
        except:
            import builtins as __builtin__
        __builtin__._ip = shell
        __builtin__.get_ipython = get_ipython
        
        # We want to print to stdout/err as usual.
        io.stdout = original_stdout
        io.stderr = original_stderr

        self.ipython = shell
開發者ID:JoshuaPK,項目名稱:Pydev,代碼行數:39,代碼來源:pydev_ipython_console_011.py

示例7: pudb_f_v10

# 需要導入模塊: from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell [as 別名]
# 或者: from IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell import instance [as 別名]
import os

try:
    from IPython import ipapi
except ImportError:
    from IPython.frontend.terminal.interactiveshell import \
            TerminalInteractiveShell
    ip = TerminalInteractiveShell.instance()
    _ipython_version = (0, 11)
else:
    ip = ipapi.get()
    _ipython_version = (0, 10)


def pudb_f_v10(self, arg):
    """ Debug a script (like %run -d) in IPython process, using PuDB.

    This conforms to IPython version 0.10

    Usage:

    %pudb test.py [args]
        Run script test.py under PuDB.
    """

    if not arg.strip():
        print __doc__
        return

    from IPython.genutils import arg_split
    args = arg_split(arg)
開發者ID:alonho,項目名稱:pudb,代碼行數:33,代碼來源:ipython.py


注:本文中的IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell.instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。