当前位置: 首页>>代码示例>>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;未经允许,请勿转载。