Skip to content

Commit

Permalink
[python3/en] Add examples to Bool operators with ints (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostduck authored and vendethiel committed Jan 28, 2017
1 parent 20b2a9a commit 05e4c41
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python3.html.markdown
Expand Up @@ -71,11 +71,14 @@ True and False # => False
False or True # => True

# Note using Bool operators with ints
# False is 0 and True is 1
# Don't mix up with bool(ints) and bitwise and/or (&,|)
0 and 2 # => 0
-5 or 0 # => -5
0 == False # => True
2 == True # => False
1 == True # => True
-5 != False != True #=> True

# Equality is ==
1 == 1 # => True
Expand Down

1 comment on commit 05e4c41

@antofthy
Copy link

@antofthy antofthy commented on 05e4c41 Sep 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a python newbie, but very experienced programmer.

On the page you have the expression...
-5 != False != True #=> True

This made absolutely no sense to me as a newbie, as I read that expression as being equivalent to
(-5 != False) != True

Which is of course False, Not True.

Until I saw further down the page...
# Comparisons can be chained!

I would suggest you move that expression to the 'chained' section, and then add the explanation...

-5 != False != True #=> True
# chained to be equivalent to   (-5 != False) and (False != True)

Remember this doc is for newbies (like me), and you should not example something before it is introduced.

Thank you
Anthony

Please sign in to comment.