有类似于Pylint的工具吗?它能够查看Python脚本(或运行它),并确定每行代码(或函数)需要哪个版本的Python。
例如,理论上的使用方式:
$ magic_tool <EOF
with something:
pass
EOF
1: 'with' statement requires Python 2.6 or greater
$ magic_tool <EOF
class Something:
@classmethod
def blah(cls):
pass
EOF
2: classmethod requires Python 2.2 or greater
$ magic_tool <EOF
print """Test
"""
EOF
1: Triple-quote requires Python 1.5 of later
这种事情可能吗?我想最简单的方法就是将所有Python版本都放在磁盘上,使用每个版本运行脚本,看看会出现什么错误。