visualstudio_py_repl.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pythonVSCode 作者: DonJayamanne 项目源码 文件源码
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()
        if stripped_code:
            if sys.platform == 'cli':
                code_to_send = ''
                for line in stripped_code.split('\n'):
                    stripped = line.strip()
                    if (stripped.startswith('#') or not stripped) and not code_to_send:
                        continue
                    code_to_send += line + '\n'

                code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
                dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
                if dispatcher is not None:
                    dispatcher(self.python_executor(code))
                else:
                    code.Execute(self.exec_mod)
            else:
                code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
                self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
                exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号