__init__.py 文件源码

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

项目:pipless 作者: d0c-s4vage 项目源码 文件源码
def _run_single_command(cmd):
    """Run a single command inside the virtual environment
    """
    builtins = __builtins__

    # this is how the python -c command works
    sys.argv.insert(0, "-c")

    import __main__
    __main__.__dict__.clear()
    __main__.__dict__.update(dict(
        __name__     = "__main__",

        # file is not defined when 'python -c "print(__file__)"' is run
        #__file__     = script_file,

        __builtins__ = builtins
    ))
    globals = __main__.__dict__
    locals = globals

    code = compile(cmd, "<string>", "single")
    exec code in globals, locals
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号