【发布时间】:2012-02-03 14:04:42
【问题描述】:
这样给变量赋值会被认为是不好的风格吗?
x = "foobar" or None
y = some_variable or None
在上面的示例中,x 获取值 'foobar'。
【问题讨论】:
-
这不是“副作用”。
-
@Ramin 我知道您没有分配布尔值。我的意思是我没有看到任何side effect。
-
@Ramin:“有点不寻常的行为”、“副作用”在计算机科学中的含义非常不同。 en.wikipedia.org/wiki/Side_effect_(computer_science)
-
是的,Python 拥有它们,可怕、黑暗、危险(Haskeller)
标签: python coding-style variable-assignment