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


Python InteractiveInterpreter.runsource方法代碼示例

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


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

示例1: runsource

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def runsource(self, source):
        "Extend base class method: Stuff the source in the line cache first"
        filename = self.stuffsource(source)
        self.more = 0
        self.save_warnings_filters = warnings.filters[:]
        warnings.filterwarnings(action="error", category=SyntaxWarning)
        if isinstance(source, types.UnicodeType):
            from idlelib import IOBinding
            try:
                source = source.encode(IOBinding.encoding)
            except UnicodeError:
                self.tkconsole.resetoutput()
                self.write("Unsupported characters in input\n")
                return
        try:
            # InteractiveInterpreter.runsource() calls its runcode() method,
            # which is overridden (see below)
            return InteractiveInterpreter.runsource(self, source, filename)
        finally:
            if self.save_warnings_filters is not None:
                warnings.filters[:] = self.save_warnings_filters
                self.save_warnings_filters = None 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:24,代碼來源:PyShell.py

示例2: runsource

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def runsource(self, source):
        "Extend base class method: Stuff the source in the line cache first"
        filename = self.stuffsource(source)
        self.more = 0
        self.save_warnings_filters = warnings.filters[:]
        warnings.filterwarnings(action="error", category=SyntaxWarning)
        # at the moment, InteractiveInterpreter expects str
        assert isinstance(source, str)
        #if isinstance(source, str):
        #    from idlelib import IOBinding
        #    try:
        #        source = source.encode(IOBinding.encoding)
        #    except UnicodeError:
        #        self.tkconsole.resetoutput()
        #        self.write("Unsupported characters in input\n")
        #        return
        try:
            # InteractiveInterpreter.runsource() calls its runcode() method,
            # which is overridden (see below)
            return InteractiveInterpreter.runsource(self, source, filename)
        finally:
            if self.save_warnings_filters is not None:
                warnings.filters[:] = self.save_warnings_filters
                self.save_warnings_filters = None 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:26,代碼來源:PyShell.py

示例3: runsource

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def runsource(self, source):
        "Extend base class method: Stuff the source in the line cache first"
        filename = self.stuffsource(source)
        self.more = 0
        self.save_warnings_filters = warnings.filters[:]
        warnings.filterwarnings(action="error", category=SyntaxWarning)
        if isinstance(source, unicode) and IOBinding.encoding != 'utf-8':
            try:
                source = '# -*- coding: %s -*-\n%s' % (
                        IOBinding.encoding,
                        source.encode(IOBinding.encoding))
            except UnicodeError:
                self.tkconsole.resetoutput()
                self.write("Unsupported characters in input\n")
                return
        try:
            # InteractiveInterpreter.runsource() calls its runcode() method,
            # which is overridden (see below)
            return InteractiveInterpreter.runsource(self, source, filename)
        finally:
            if self.save_warnings_filters is not None:
                warnings.filters[:] = self.save_warnings_filters
                self.save_warnings_filters = None 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:25,代碼來源:PyShell.py

示例4: execsource

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def execsource(self, source):
        "Like runsource() but assumes complete exec source"
        filename = self.stuffsource(source)
        self.execfile(filename, source) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:6,代碼來源:PyShell.py

示例5: runit

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def runit(self):
        line = self.text.get("iomark", "end-1c")
        # Strip off last newline and surrounding whitespace.
        # (To allow you to hit return twice to end a statement.)
        i = len(line)
        while i > 0 and line[i-1] in " \t":
            i = i-1
        if i > 0 and line[i-1] == "\n":
            i = i-1
        while i > 0 and line[i-1] in " \t":
            i = i-1
        line = line[:i]
        more = self.interp.runsource(line) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:15,代碼來源:PyShell.py

示例6: runit

# 需要導入模塊: from code import InteractiveInterpreter [as 別名]
# 或者: from code.InteractiveInterpreter import runsource [as 別名]
def runit(self):
        line = self.text.get("iomark", "end-1c")
        # Strip off last newline and surrounding whitespace.
        # (To allow you to hit return twice to end a statement.)
        i = len(line)
        while i > 0 and line[i-1] in " \t":
            i = i-1
        if i > 0 and line[i-1] == "\n":
            i = i-1
        while i > 0 and line[i-1] in " \t":
            i = i-1
        line = line[:i]
        self.interp.runsource(line) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:15,代碼來源:PyShell.py


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