简体   繁体   English

检查重新格式化Python代码的工具不变

[英]Tool to check reformatting Python code does not change meaning

Is there a tool, or method, to check that given two python files, they will parse identically? 是否有工具或方法来检查给定的两个python文件,它们将进行相同的解析?

The specific use case I'm thinking of: I'm currently making a large number of code changes to improve readability. 我正在考虑的特定用例:我目前正在进行大量代码更改以提高可读性。 Many of them (reindenting, removing spaces around = in keyword arguments) introduce no changes to the meaning of the code (unless done incorrectly) whatsoever. 其中许多代码(重新缩进,删除关键字参数中=周围的空格)无论如何都不会改变代码的含义(除非做得不正确)。 I would be able to make such changes more quickly if I could quickly verify that the new code was identical to the old, as far as Python is concerned. 如果我可以快速验证新代码与旧代码是否相同(就Python而言),我将能够更快地进行此类更改。

也许使用dis.dis()转储指令并比较或校验和输出?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM