以下逻辑表达式的使用是否符合Pythonic / pep8标准?
This:
x = a or b
instead of:
if not a: x = b else: x = a
This:
x = a and b
instead of:
if not a: x = a else: x = b
(The curve-ball?) This:
x = x or y
instead of:
if not x: x = y
and
和or
将具有布尔结果,因为这是它们当前行为的唯一应用。 - Ericattr = node.hasAttr('y') and node.getAttr('y') == 'True'
。 - Scruffynode.get('y', False)
更加简单明了。 - Blender