mhu*_*big 2 python unit-testing assert
我想知道什么是更好/更好:
>>> def command():
... return False
...
>>> assert command() == False
>>> assert command() is False
>>> assert not command()
Run Code Online (Sandbox Code Playgroud)
干杯,马库斯
可以在此处研究编码约定: PEP 8 Python代码样式指南
在那里你会发现:
不要使用==将布尔值与True或False进行比较
Yes: if greeting:
No: if greeting == True:
Worse: if greeting is True:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4730 次 |
| 最近记录: |