Python 2 到 3 在函数参数周围添加额外的括号
Python 2to3 adding extra parenthesis around functional argument
我有点困惑,为什么 2to3
费心将我的打印参数包含在一组额外的括号中,这些参数已经是函数式样式。例如
print("\t[Warn] Can not connect {}".format(ssid))
变成
print(("\t[Warn] Can not connect {}".format(ssid)))
这些本质上是保守的误报吗?我在想也许格式函数中的尾随 )
正在抛出它的逻辑。
来自文档
When the -p is passed, 2to3 treats print as a function instead of a statement. This is useful when from future import print_function is being used. If this option is not given, the print fixer will surround print calls in an extra set of parentheses because it cannot differentiate between the print statement with parentheses (such as print ("a" + "b" + "c")) and a true function call.
我有点困惑,为什么 2to3
费心将我的打印参数包含在一组额外的括号中,这些参数已经是函数式样式。例如
print("\t[Warn] Can not connect {}".format(ssid))
变成
print(("\t[Warn] Can not connect {}".format(ssid)))
这些本质上是保守的误报吗?我在想也许格式函数中的尾随 )
正在抛出它的逻辑。
来自文档
When the -p is passed, 2to3 treats print as a function instead of a statement. This is useful when from future import print_function is being used. If this option is not given, the print fixer will surround print calls in an extra set of parentheses because it cannot differentiate between the print statement with parentheses (such as print ("a" + "b" + "c")) and a true function call.