Skip to content Skip to sidebar Skip to footer

Best Practice For Python: Assert Command() == False

I wonder what is better/best: >>> def command(): ... return False ... >>> assert command() == False >>> assert command() is False >>> assert

Solution 1:

Coding conventions can be studied here: PEP 8 Style Guide for Python Code

There you will find:

Don't compare boolean values to True or False using ==

Yes:if greeting:
No:if greeting == True:
Worse:if greeting isTrue:

Solution 2:

Post a Comment for "Best Practice For Python: Assert Command() == False"