import diff_match_patch as dmp_module dmp_init = dmp_module.diff_match_patch() old = ' \"\"\"Rotate matrix 90 degrees clockwise.\"\"\"\n t = transpose(matrix)\n # BUG: this is counter-clockwise.\n return t[::-1]\n' new = ' \"\"\"Rotate matrix 90 degrees clockwise.\"\"\"\n t = transpose(matrix)\n # BUG: this is counter-clockwise.\n return [row[::-1] for row in t]\n' diffs = dmp_init.diff_main(old, new) dmp_init.diff_cleanupSemantic(diffs) patches = dmp_init.patch_make(old, diffs) patched, res = dmp_init.patch_apply(patches, old) print('patched:', repr(patched))