summaryrefslogtreecommitdiffhomepage
path: root/python3.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'python3.html.markdown')
-rw-r--r--python3.html.markdown9
1 files changed, 6 insertions, 3 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index 839d66fd..02745117 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -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
@@ -143,13 +146,13 @@ None # => None
"etc" is None # => False
None is None # => True
-# None, 0, and empty strings/lists/dicts all evaluate to False.
+# None, 0, and empty strings/lists/dicts/tuples all evaluate to False.
# All other values are True
bool(0) # => False
bool("") # => False
bool([]) # => False
bool({}) # => False
-
+bool(()) # => False
####################################################
## 2. Variables and Collections
@@ -491,7 +494,7 @@ next(our_iterator) # => "one"
next(our_iterator) # => "two"
next(our_iterator) # => "three"
-# After the iterator has returned all of its data, it gives you a StopIterator Exception
+# After the iterator has returned all of its data, it gives you a StopIteration Exception
next(our_iterator) # Raises StopIteration
# You can grab all the elements of an iterator by calling list() on it.