__init__.py 文件源码

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

项目:pipless 作者: d0c-s4vage 项目源码 文件源码
def _run_script(script_file):
    """Run the script at the provided path

    :param str script_file: A path to a python script to run
    """
    builtins = __builtins__

    import __main__
    __main__.__dict__.clear()
    __main__.__dict__.update(dict(
        __name__     = "__main__",
        __file__     = script_file,
        __builtins__ = builtins
    ))
    globals = __main__.__dict__
    locals = globals

    # repr will put the script_file into quotes and escape any
    # unruly characters

    # NOTE that at this point, sys.argv will already have been reset
    # so that it will look like (from script_file's point of view),
    # that it was the first file run instead of pipless.
    exec 'execfile({})'.format(repr(script_file)) in globals, locals
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号