recipe-574437.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def compile_py3k(source, filename, mode, *args, **kwds):
    """
py3k example:
import py3to2; from py3to2 import print_py3k
src = "a, b, *c = 1, 2, 3, 4, 5; print('a =', a); print('b =', b); print('c =', c)"
code_object = py3to2.compile_py3k(src, '', 'exec')
exec(code_object, globals())

"""
    s = "x = compile(%s, %s, %s, *%s, **%s); x = codetree(x).py3to2()"%tuple(repr(x) for x in (source, filename, mode, args, kwds))
    server.input(s)
    x = server.get('x')
    x = eval(x)
    x = x.compile()
    if 1: dis.dis(x)
    return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号