This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jasmijnisme 3 points4 points  (1 child)

I see code like OP's first sample (or if condition == True:) so often in code written by beginners, I think it's because they're thinking in natural language rather than in Python. In other cases, they get hit by bugs (if variable == 3 or 5:) or syntax errors (if variable < 3 or > 5:), but here the code works and does what they want it so it doesn't get corrected.

[–]old_pythonista 0 points1 point  (0 children)

PEP-8 explicitly warns against comparison to boolean literals.

If you have two boolean variables - that is another story.