what are booleans?
Imagine we divide the universe in two and the options are things that are the True group and the False group. These are the booleans: True and False.
I used assertIs and assertIsNot in test_assertion_error_w_false and test_assertion_error_w_true in the assertion_error project, where I saw that
I want to test what groups Python places the objects seen so far (None, integers, floats, strings, tuples, lists, sets and dictionaries). Which do you think will be in the False group or the True group?
preview
I have these tests by the end of the chapter
1import unittest
2
3
4class TestBooleans(unittest.TestCase):
5
6 def test_what_is_false(self):
7 self.assertIsInstance(False, (bool, int))
8 self.assertNotIsInstance(
9 False,
10 (
11 float, tuple, str,
12 list, set, dict,
13 )
14 )
15 self.assertIs(False, False)
16 self.assertIs(bool(False), False)
17 self.assertFalse(bool(False))
18 self.assertFalse(False)
20 def test_what_is_true(self):
21 self.assertIsInstance(True, (bool, int))
22 self.assertNotIsInstance(
23 True,
24 (
25 float, tuple, str,
26 list, set, dict,
27 )
28 )
29 self.assertIs(True, True)
30 self.assertIs(bool(True), True)
31 self.assertTrue(bool(True))
32 self.assertTrue(True)
34 def assert_is_not_the_same_as_false_or_true(self, an_object):
35 self.assertNotEqual(an_object, False)
36 self.assertIsNot(an_object, False)
37 self.assertNotEqual(an_object, True)
38 self.assertIsNot(an_object, True)
39
40 def assert_is_falsy(self, an_object):
41 self.assert_is_not_the_same_as_false_or_true(an_object)
42 self.assertFalse(bool(an_object))
43 self.assertFalse(an_object)
45 def assert_is_truthy(self, an_object):
46 self.assert_is_not_the_same_as_false_or_true(an_object)
47 self.assertTrue(bool(an_object))
48 self.assertTrue(an_object)
49
50 def test_is_none_falsy_or_truthy(self):
51 self.assert_is_falsy(None)
53 def test_is_an_integer_falsy_or_truthy(self):
54 self.assert_is_truthy(-1)
55
56 self.assertEqual(0, False)
57 self.assertIsNot(0, False)
58 self.assertNotEqual(0, True)
59 self.assertIsNot(0, True)
60 self.assertFalse(bool(0))
61 self.assertFalse(0)
62
63 a_positive_integer = 1
64 self.assertNotEqual(a_positive_integer, False)
65 self.assertIsNot(a_positive_integer, False)
66 self.assertEqual(1, True)
67 self.assertIsNot(a_positive_integer, True)
68 self.assertTrue(bool(a_positive_integer))
69 self.assertTrue(a_positive_integer)
71 def test_is_a_float_falsy_or_truthy(self):
72 self.assert_is_truthy(-0.1)
73
74 self.assertEqual(0.0, False)
75 self.assertIsNot(0.0, False)
76 self.assertNotEqual(0.0, True)
77 self.assertIsNot(0.0, True)
78 self.assertFalse(bool(0.0))
79 self.assertFalse(0.0)
80
81 self.assert_is_truthy(0.1)
83 def test_is_a_string_falsy_or_truthy(self):
84 self.assert_is_falsy(str())
85 self.assert_is_truthy('string with things')
86
87 def test_is_a_tuple_falsy_or_truthy(self):
88 self.assert_is_falsy(tuple())
89 self.assert_is_truthy((0, 1, 2, 'n'))
91 def test_is_a_list_falsy_or_truthy(self):
92 self.assert_is_falsy(list())
93 self.assert_is_truthy([0, 1, 2, 'n'])
94
95 def test_is_a_set_falsy_or_truthy(self):
96 self.assert_is_falsy(set())
97 self.assert_is_truthy({0, 1, 2, 'n'})
98
99 def test_is_a_dictionary_falsy_or_truthy(self):
100 self.assert_is_falsy(dict())
101 self.assert_is_truthy({'key': 'value'})
104# NOTES
105# the value of True is 1
106# bool(a dictionary with things) is True
107# bool(a set with things) is True
108# bool(a list with things) is True
109# bool(a tuple with things) is True
110# bool(a string with things) is True
111# bool(a positive number) is True
112# bool(a negative number) is True
113# True is True
114# True is an integer
115# True is a boolean
116# True is NOT False
117# the value of False is 0
118# bool(the empty dictionary) is False
119# bool(the empty set) is False
120# bool(the empty list) is False
121# bool(the empty tuple) is False
122# bool(the empty string) is False
123# bool(zero) is False
124# bool(None) is False
125# False is False
126# False is an integer
127# False is a boolean
128# False is NOT True
129
130
131# Exceptions seen
132# AssertionError
questions about Booleans
Questions to think about as we divide Python’s basic objects into False and True
start the project
I name this project
booleansI open a terminal
I use uv to make a directory for the project and initialize it
I change directory to the project
I make a directory for the tests
mkdir testsI make the
testsdirectory a Python packageDanger
use 2 underscores (__) before and after
initfor__init__.pynot_init_.pytouch tests/__init__.pyNew-Item tests/__init__.pyI make an empty file for the tests in the
testsfoldertouch tests/test_booleans.pyNew-Item tests/test_booleans.pyI open
test_booleans.pyI add the first failing test to
test_booleans.py1import unittest 2 3 4class TestBooleans(unittest.TestCase): 5 6 def test_failure(self): 7 self.assertEqual(False, True)I go back to the terminal
I use echo to add pytest to
requirements.txtecho "pytest" > requirements.txtI add pytest-watcher to the requirements file
echo "pytest-watcher" >> requirements.txtthe terminal goes back to the command line.
I use Out-File to add pytest to
requirements.txt"pytest" | Out-File requirements.txt -Encoding UTF8I add pytest-watcher to the requirements file
"pytest-watcher" >> requirements.txt
I use uv to install pytest-watcher with the requirements file
I add a git commit message
I use pytest-watcher to run the tests automatically
the terminal is my friend, and shows AssertionError
======================== FAILURES ======================== _______________ TestBooleans.test_failure ________________ self = <tests.test_booleans.TestBooleans testMethod=test_failure> def test_failure(self): > self.assertEqual(False, True) E AssertionError: False != True tests/test_booleans.py:7: AssertionError ================ short test summary info ================= FAILED tests/test_booleans.py::TestBooleans::test_failure - AssertionError: False != True =================== 1 failed in X.YZs ====================if the terminal does not show the same error, then check if
your
tests/__init__.pyhas two underscores (__) before and afterinitfor__init__.pynot_init_.pyyou ran
echo "pytest-watcher" >> requirements.txt, to addpytest-watcherto the requirements file
and try
uv run pytest-watcher . --now --patterns "**/*.py"againI add AssertionError to the list of Exceptions seen, in
test_booleans.pyI change True to False in the assertion
the test passes.
test_what_is_false
RED: make it fail
I remove test_failure
I add test_what_is_false with assertNotIsInstance
4class TestBooleans(unittest.TestCase):
5
6 def test_what_is_false(self):
7 self.assertNotIsInstance(False, bool)
8
9
10# Exceptions seen
11# AssertionError
the terminal is my friend, and shows AssertionError
AssertionError: False is an instance
of <class 'bool'>
this was also in test_is_none_a_boolean.
GREEN: make it pass
I change assertNotIsInstance to the assertIsInstance method
6 def test_what_is_false(self):
7 # self.assertNotIsInstance(False, bool)
8 self.assertIsInstance(False, bool)
9
10
11# Exceptions seen
the test passes.
REFACTOR: make it better
I add a comment
also from test_is_none_a_boolean.
test_when_year_of_birth_is_not_an_integer showed me that False is an integer. I add an assertion for it
the terminal is my friend, and shows AssertionError
AssertionError: False is an instance of <class 'int'>I add a comment
I change assertNotIsInstance to assertIsInstance
the test passes.
how to test if something is an instance of more than one object
The instance methods can take a tuple of objects.
-
the terminal is my friend, and shows AssertionError
AssertionError: False is an instance of <class 'bool'> I change assertNotIsInstance to assertIsInstance for
(False, (bool, int))the test passes.
I comment out the first assertions since they are covered by the new one
I add an assertion to test if False is a float
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'float'>I change assertIsInstance to assertNotIsInstance for
(False, float)the test passes.
I add an assertion to test if False is a string
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'str'>I change assertIsInstance to assertNotIsInstance for
(False, str)the test passes.
I add an assertion to test if False is a tuple
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'tuple'>I change assertIsInstance to assertNotIsInstance for
(False, tuple)the test passes.
I add an assertion to test if False is a list
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'list'>I change assertIsInstance to assertNotIsInstance for
(False, list)the test passes.
I add an assertion to test if False is a set
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'set'>I change assertIsInstance to assertNotIsInstance for
(False, set)the test passes.
I add an assertion to test if False is a dictionary
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of <class 'dict'>I change assertIsInstance to assertNotIsInstance for
(False, dict)the test passes.
I use a tuple with float, str, tuple, list, set and dict with a call to assertIsInstance
the terminal is my friend, and shows AssertionError
AssertionError: False is not an instance of any of ( <class 'float'>, <class 'tuple'>, <class 'str'>, <class 'list'>, <class 'set'>, <class 'dict'> )I change assertIsInstance to assertNotIsInstance
the test passes.
I use the assertIsNot method like I did in test_assertion_error_w_false
the terminal is my friend, and shows AssertionError
AssertionError: unexpectedly identical: Falsebecause False is False.
I change assertIsNot to assertIs for
(False, False)the test passes. I know this from test_assertion_error_w_false.
how to test if something is grouped as False
I can test if Python groups an object as False with the bool built-in function from The Python Standard Library. It returns False or True for the object given in parentheses.
RED: make it fail
I add an assertion with a call to bool
the terminal is my friend, and shows AssertionError
AssertionError: unexpectedly identical: Falsebecause this happens when
assertIsNot(bool(False), False)runsassertIsNot(bool(False), False) assertIsNot(False , False)which raises AssertionError since False, which is the result of
bool(False)is False.bool(anything)returns False or True for the thing in parentheses.
I add a comment
GREEN: make it pass
I change the assertIsNot to assertIs to make the statement True
33 # self.assertIsNot(False, False)
34 self.assertIs(False, False)
35 # self.assertIsNot(bool(False), False)
36 self.assertIs(bool(False), False)
37
38
39# NOTES
the test passes because bool(False) is equal to False.
another way to test if something is grouped as False
The unittest.TestCase class has a method I can use to test if the result of calling the bool built-in function with an object is False - assertFalse.
assertFalse(an_object)
which is like
assertIs(bool(an_object), False)
it raises AssertionError if the object in parentheses is grouped as True.
RED: make it fail
I add assertFalse to the test
the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause this happens when
assertFalse(bool(True))runsassertFalse(bool(True)) assertFalse(True)which raises AssertionError since the result of
bool(True)is True, not False.I add a comment
GREEN: make it pass
I change True to False in the parentheses
35 # self.assertIsNot(bool(False), False)
36 self.assertIs(bool(False), False)
37 # self.assertFalse(bool(True))
38 self.assertFalse(bool(False))
39
40
41# NOTES
the test passes because bool(False) is False.
REFACTOR: make it better
I can skip bool and get the same result. I add another call to the assertFalse method
the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause
bool(True)is True.I change True to False in the parentheses
the test passes because
bool(False)is False.The assertFalse method raises AssertionError if the result of a call to the bool built-in function with an object is True.
I remove the commented lines and single instance tests for float, str, tuple, list, set and dict
I open a new terminal then make sure I am in the
booleansfolderassertFalse(an_object)is likeassertIs(bool(an_object), False), with less words.
test_what_is_true
RED: make it fail
I add test_what_is_true with assertNotIsInstance
17 self.assertFalse(bool(False))
18 self.assertFalse(False)
19
20 def test_what_is_true(self):
21 self.assertNotIsInstance(True, (bool, int))
22
23
24# NOTES
the terminal is my friend, and shows AssertionError
AssertionError: True is an instance
of <class 'bool'>
this was also in test_is_none_a_boolean, without the tuple of objects.
GREEN: make it pass
I change assertNotIsInstance to the assertIsInstance method
18 self.assertFalse(False)
19
20 def test_what_is_true(self):
21 # self.assertNotIsInstance(True, (bool, int))
22 self.assertIsInstance(True, (bool, int))
23
24
25 # NOTES
the test passes.
REFACTOR: make it better
I add comments
I add a call to assertIsInstance with a tuple that has float, str, tuple, list, set and dict
the terminal is my friend, and shows AssertionError
AssertionError: True is not an instance of any of ( <class 'float'>, <class 'tuple'>, <class 'str'>, <class 'list'>, <class 'set'>, <class 'dict'> )I change assertIsInstance to the assertNotIsInstance method
the test passes.
I use the assertIsNot method like I did in test_assertion_error_w_true
the terminal is my friend, and shows AssertionError
AssertionError: unexpectedly identical: Truebecause True is True.
I change assertIsNot to assertIs for
(True, True)the test passes. I know this from test_assertion_error_w_true.
how to test if something is grouped as True
I can test if Python groups an object as True with the bool built-in function since it returns False or True for the object given in parentheses.
RED: make it fail
I add an assertion with a call to bool
the terminal is my friend, and shows AssertionError
AssertionError: unexpectedly identical: Truebecause this happens when
assertIsNot(bool(True), True)runsassertIsNot(bool(True), True) assertIsNot(True , True)which raises AssertionError since True, which is the result of
bool(True)is True.bool(anything)returns False or True for the thing in parentheses.
I add a comment
GREEN: make it pass
I change assertIsNot to assertIs
31 # self.assertIsNot(True, True)
32 self.assertIs(True, True)
33 # self.assertIsNot(bool(True), True)
34 self.assertIs(bool(True), True)
35
36
37# NOTES
the test passes because bool(True) is True.
another way to test if something is grouped as True
The unittest.TestCase class has a method I can use to test if the result of calling the bool built-in function with an object is True - assertTrue.
assertTrue(an_object)
which is like
assertIs(bool(an_object), True)
it raises AssertionError if the object in parentheses is grouped as False.
RED: make it fail
I add assertTrue to the test
the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause this happens when
assertTrue(bool(False))runsassertTrue(bool(False)) assertTrue(False)which raises AssertionError since the result of
bool(False)is False not True.I add a comment
GREEN: make it pass
I change False to True in the parentheses
33 # self.assertIsNot(bool(True), True)
34 self.assertIs(bool(True), True)
35 # self.assertTrue(bool(False))
36 self.assertTrue(bool(True))
37
38
39# NOTES
the test passes because bool(True) is True.
REFACTOR: make it better
I add another call to the assertTrue method without bool to show that I can skip it
the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause
bool(False)is False.I change False to True in the parentheses
the test passes because
bool(True)is True.The assertTrue method raises AssertionError if the result of a call to the bool built-in function with an object is False.
I remove the commented lines from test_what_is_true
I add a git commit message in the other terminal
test_is_none_falsy_or_truthy
Is None grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for None, False
34 def test_is_none_falsy_or_truthy(self):
35 # self.assertEqual(None, False)
36 self.assertNotEqual(None, False)
37
38
39# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if None is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: None is not FalseI change assertIs to assertIsNot for
None, Falsethe test passes because None is not the same object as False.
I add an assertion for if None is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: None != TrueI change assertEqual to assertNotEqual for
None, Truethe test passes.
I add an assertion for if None is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: None is not TrueI change assertIs to assertIsNot for
None, Truethe test passes because None is not the same object as True.
I add an assertion for
bool(None)the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(None)is False.I change assertTrue to assertFalse for
bool(None)the test passes.
I add a comment
I add an assertion for None without bool
the terminal is my friend, and shows AssertionError
AssertionError: None is not trueA reminder of test_assertion_error_w_true.
I change assertTrue to assertFalse for None
the test passes because the result of
bool(None)is False.I remove the commented lines from test_is_none_falsy_or_truthy
test_is_an_integer_falsy_or_truthy
Is an integer grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for -1, False
42 def test_is_an_integer_falsy_or_truthy(self):
43 # self.assertEqual(-1, False)
44 self.assertNotEqual(-1, False)
45
46
47# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if a negative integer is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: -1 is not FalseI change assertIs to assertIsNot for
-1, Falsethe test passes because an integer is not the same object as False.
I add an assertion for if a negative integer is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: -1 != TrueI change assertEqual to assertNotEqual for
-1, Truethe test passes.
I add an assertion for if a negative integer is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: -1 is not TrueI change assertIs to assertIsNot for
-1, Truethe test passes because an integer is not the same object as True.
I add an assertion for
bool(-1)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsethis means the result of
bool(-1)is True.I change assertFalse to assertTrue for
bool(-1)the test passes.
I use
-1for all the integers (whole numbers without decimals) that are smaller than0.
I add a comment
I add an assertion for
-1without boolthe terminal is my friend, and shows AssertionError
AssertionError: -1 is not falsebecause the result of
bool(-1)is True.I change assertFalse to assertTrue for
-1I add a variable for
-1I use the variable to remove repetition of
-1the test is still green.
I remove the commented lines from test_is_an_integer_falsy_or_truthy
I add an assertion to test if
0is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: 0 == Falsea reminder that False is an integer, the test also shows that the value of False is
0.I change assertNotEqual to assertEqual for
0, Falsethe test passes.
I add an assertion to test if
0is the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: 0 is not FalseI change assertIs to assertIsNot for
0, Falsethe test passes because an integer is not the same object as False. This is another example of how is and equal are different
I add an assertion to see if
0is equal to Truethe terminal is my friend, and shows AssertionError
AssertionError: 0 != TrueI change assertEqual to assertNotEqual for
0, Truethe test passes.
I add an assertion for if
0is the same object as Truethe terminal is my friend, and shows AssertionError
AssertionError: 0 is not TrueI change assertIs to assertIsNot for
0, Truethe test passes because an integer is not the same object as True.
-
the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(0)is False. I change assertTrue to assertFalse for
bool(0)the test passes.
I add a comment
I add an assertion for
0without boolthe terminal is my friend, and shows AssertionError
AssertionError: 0 is not truebecause the result of
bool(0)is False.I change assertTrue to assertFalse for
0the test passes because the result of
bool(0)is False.I remove the commented lines from test_is_an_integer_falsy_or_truthy
I add an assertion to test if
1is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: 1 != FalseI change assertEqual to assertNotEqual for
1, Falsethe test passes.
I add an assertion to see if
1is the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: 1 is not FalseI change assertIs to assertIsNot for
1, Falsethe test passes.
I add an assertion to see if
1is equal to Truethe terminal is my friend, and shows AssertionError
AssertionError: 1 == Truea reminder that True is an integer and its value is
1.I change assertNotEqual to assertEqual for
1, Truethe test passes.
I add an assertion for if
1is the same object as Truethe terminal is my friend, and shows AssertionError
AssertionError: 1 is not TrueI change assertIs to assertIsNot for
1, True-
the terminal is my friend, and shows AssertionError
AssertionError: True is not false I change assertFalse to assertTrue for
bool(1)the test passes.
I add a comment
I add an assertion for
1without boolthe terminal is my friend, and shows AssertionError
AssertionError: 1 is not falsebecause the result of
bool(1)is True.I change assertFalse to assertTrue for
1I add a variable for
1I use the variable to remove repetition of
1for the other statements and keepself.assertEqual(1, True)since it shows the exact value of Truethe test is still green.
I remove the commented lines from test_is_an_integer_falsy_or_truthy
0 is grouped as False. Positive and Negative Integers are grouped as True.
test_is_a_float_falsy_or_truthy
Is a float grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for a_negative_float, False
66 def test_is_a_float_falsy_or_truthy(self):
67 a_negative_float = -0.1
68 # self.assertEqual(a_negative_float, False)
69 self.assertNotEqual(a_negative_float, False)
70
71
72# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if a negative float is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: -0.1 is not FalseI change assertIs to assertIsNot for
a_negative_float, Falsethe test passes because a float is not the same object as False.
I add an assertion for if a negative float is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: -0.1 != TrueI change assertEqual to assertNotEqual for
a_negative_float, Truethe test passes.
I add an assertion for if a negative float is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: -0.1 is not TrueI change assertIs to assertIsNot for
a_negative_float, Truethe test passes because a float is not the same object as True.
I add an assertion for
bool(a_negative_float)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsethis means the result of
bool(-0.1)is True.I change assertFalse to assertTrue for
bool(a_negative_float)the test passes.
I use
-0.1for all the floats (binary floating point decimal numbers) that are smaller than0.0.
I add a comment
I add an assertion for
a_negative_floatwithout boolthe terminal is my friend, and shows AssertionError
AssertionError: -0.1 is not falsebecause the result of
bool(-0.1)is True.I change assertFalse to assertTrue for
a_negative_floatI remove the commented lines from test_is_a_float_falsy_or_truthy
I add an assertion to test if
0.0is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.0 == Falsethe test also shows that
0.0is equal to False, whose value is0.I change assertNotEqual to assertEqual for
0.0, Falsethe test passes.
I add an assertion to test if
0.0is the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: 0.0 is not FalseI change assertIs to assertIsNot for
0.0, Falsethe test passes because a float is not the same object as False. This is another example of how is and equal are different
I add an assertion to see if
0.0is equal to Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.0 != TrueI change assertEqual to assertNotEqual for
0.0, Truethe test passes.
I add an assertion for if
0.0is the same object as Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.0 is not TrueI change assertIs to assertIsNot for
0.0, Truethe test passes because a float is not the same object as True.
I add an assertion for
bool(0.0)the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(0.0)is False.I change assertTrue to assertFalse for
bool(0.0)the test passes.
I add a comment
I add an assertion for
0.0without boolthe terminal is my friend, and shows AssertionError
AssertionError: 0.0 is not truebecause the result of
bool(0.0)is False.I change assertTrue to assertFalse for
0.0the test passes because the result of
bool(0.0)is False.I remove the commented lines from test_is_a_float_falsy_or_truthy
I add an assertion to test if a float bigger than
0.0is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.1 != FalseI change assertEqual to assertNotEqual for
a_positive_float, Falsethe test passes.
I add an assertion to see if
a_positive_floatis the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: 0.1 is not FalseI change assertIs to assertIsNot for
a_positive_float, Falsethe test passes.
I add an assertion to see if
0.1is equal to Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.1 != TrueI change assertEqual to assertNotEqual for
a_positive_float, Truethe test passes.
I add an assertion for if
a_positive_floatis the same object as Truethe terminal is my friend, and shows AssertionError
AssertionError: 0.1 is not TrueI change assertIs to assertIsNot for
a_positive_float, TrueI add an assertion for
bool(a_positive_float)the terminal is my friend, and shows AssertionError
AssertionError: True is not falseI change assertFalse to assertTrue for
bool(a_positive_float)the test passes.
I add a comment
I add an assertion for
a_positive_floatwithout boolthe terminal is my friend, and shows AssertionError
AssertionError: 0.1 is not falsebecause the result of
bool(0.1)is True.I change assertFalse to assertTrue for
0.1I remove the commented lines from test_is_a_float_falsy_or_truthy
I make the comments for
# bool(0.1) is True,# bool(-0.1) is True,# bool(1) is True,# bool(-1) is True,# bool(0.0) is Falseand# bool(0) is Falsesimpler because floats and integers are numbers and 0.0 is equal to 00.0 is grouped as False. Positive and Negative floats are grouped as True.
‘0.0’ is grouped as False. Positive and Negative floats are grouped as True.
test_is_a_string_falsy_or_truthy
Is a string grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for str(), False
88 self.assertTrue(a_positive_float)
89
90 def test_is_a_string_falsy_or_truthy(self):
91 # self.assertEqual(str(), False)
92 self.assertNotEqual(str(), False)
93
94
95# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if
str()is the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: '' is not FalseI change assertIs to assertIsNot for
str(), Falsethe test passes.
I add an assertion for if the empty string is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: '' != TrueI change assertEqual to assertNotEqual for
str(), Truethe test passes.
I add an assertion for if the empty string is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: '' is not TrueI change assertIs to assertIsNot for
str(), TrueI add an assertion for
bool(str())the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(str())is False.I change assertTrue to assertFalse for
bool(str())the test passes.
I add a comment
I add an assertion for
str()without boolthe terminal is my friend, and shows AssertionError
AssertionError: '' is not trueI change assertTrue to assertFalse for
str()I remove the commented lines from test_is_a_string_falsy_or_truthy
I add an assertion to test if a string with things is grouped as False or True
the terminal is my friend, and shows AssertionError
AssertionError: 'string with things' != FalseI change assertEqual to assertNotEqual for
a_string, Falsethe test passes.
add an assertion for if
a_stringis the same object as Falsethe terminal is my friend, and shows AssertionError
AssertionError: 'string with things' is not FalseI change assertIs to assertIsNot for
a_string, Falsethe test passes.
I add an assertion for if
a_stringis equal to Truethe terminal is my friend, and shows AssertionError
AssertionError: 'string with things' != TrueI change assertEqual to assertNotEqual for
a_string, Truethe test passes.
I add an assertion to see if
a_stringis the same object as Truethe terminal is my friend, and shows AssertionError
AssertionError: 'string with things' is not TrueI change assertIs to assertIsNot for
a_string, Truethe test passes.
I add an assertion for
bool(a_string)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause the result of
bool("string with things")is True.I change assertFalse to assertTrue for
bool(a_string)the test passes.
I add a comment
I add an assertion for
a_stringwithout boolthe terminal is my friend, and shows AssertionError
AssertionError: 'string with things' is not falsebecause the result of
bool("string with things")is True.I change assertFalse to assertTrue
I remove the commented lines from test_is_a_string_falsy_or_truthy
I change the new comments to make them clearer
The empty string is grouped as False. A string with things is grouped as True.
test_is_a_tuple_falsy_or_truthy
Is a tuple grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for tuple(), False
104 self.assertTrue(a_string)
105
106 def test_is_a_tuple_falsy_or_truthy(self):
107 # self.assertEqual(tuple(), False)
108 self.assertNotEqual(tuple(), False)
109
110
111# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if the empty tuple is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: () is not FalseI change assertIs to assertIsNot for
tuple(), Falsethe test passes.
I add an assertion for if the empty tuple is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: () != TrueI change assertEqual to assertNotEqual for
tuple(), Truethe test passes.
I add an assertion for if the empty tuple is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: () is not TrueI change assertIs to assertIsNot for
tuple(), Truethe test passes.
I add an assertion for
bool(tuple())the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(tuple())is False.I change assertTrue to assertFalse for
bool(tuple())the test passes.
I add a comment
I add an assertion for
tuple()without boolthe terminal is my friend, and shows AssertionError
AssertionError: () is not trueI change assertTrue to assertFalse
I remove the commented lines from test_is_a_tuple_falsy_or_truthy
I add an assertion to test if a tuple with things is grouped as False or True
the terminal is my friend, and shows AssertionError
AssertionError: (0, 1, 2, 'n') != FalseI change assertEqual to assertNotEqual for
a_tuple, Falsethe test passes.
I add an assertion to test if a tuple with things is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: (0, 1, 2, 'n') is not FalseI change assertIs to assertIsNot for
a_tuple, Falsethe test passes.
I add an assertion for if a tuple with things is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: (0, 1, 2, 'n') != TrueI change assertEqual to assertNotEqual for
a_tuple, Truethe test passes.
I add an assertion to test if a tuple with things is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: (0, 1, 2, 'n') is not TrueI change assertIs to assertIsNot for
a_tuple, Truethe test passes.
I add an assertion for
bool(a_tuple)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause the result of
bool((0, 1, 2, 'n'))is True.I change assertFalse to assertTrue for
bool(a_tuple)the test passes.
I add a comment
I add an assertion for a tuple with things without bool
the terminal is my friend, and shows AssertionError
AssertionError: (0, 1, 2, 'n') is not falsebecause the result of
bool((0, 1, 2, 'n'))is True.I change assertFalse to assertTrue for
a_tupleI remove the commented lines from test_is_a_tuple_falsy_or_truthy
The empty tuple is grouped as False. A tuple with things is grouped as True.
test_is_a_list_falsy_or_truthy
Is a list grouped as False or True?
RED: make it fail
GREEN: make it pass
I change assertEqual to assertNotEqual for list(), False
120 self.assertTrue(a_tuple)
121
122 def test_is_a_list_falsy_or_truthy(self):
123 # self.assertEqual(list(), False)
124 self.assertNotEqual(list(), False)
125
126
127# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if the empty list is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: [] is not FalseI change assertIs to assertIsNot for
list(), Falsethe test passes because a list is not the same object as False.
I add an assertion for if the empty list is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: [] != TrueI change assertEqual to assertNotEqual for
list(), Truethe test passes.
I add an assertion for if the empty list is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: [] is not TrueI change assertIs to assertIsNot for
list(), Truethe test passes because a list is not the same object as True.
I add an assertion for
bool(list())the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(list())is False.I change assertTrue to assertFalse for
bool(list())the test passes.
I add a comment
I add an assertion for
list()without boolthe terminal is my friend, and shows AssertionError
AssertionError: [] is not trueI change assertTrue to assertFalse for
list()I remove the commented lines from test_is_a_list_falsy_or_truthy
I add an assertion to test if a list with things is grouped as False or True
the terminal is my friend, and shows AssertionError
AssertionError: [0, 1, 2, 'n'] != FalseI change assertEqual to assertNotEqual for
a_list, Falsethe test passes.
I add an assertion for if a list with things is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: [0, 1, 2, 'n'] is not FalseI change assertIs to assertIsNot for
a_list, Falsethe test passes because a list is not the same object as False.
I add an assertion to test if a list with things is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: [0, 1, 2, 'n'] != TrueI change assertEqual to assertNotEqual for
a_list, Truethe test passes.
I add an assertion for if a list with things is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: [0, 1, 2, 'n'] is not TrueI change assertIs to assertIsNot for
a_list, Truethe test passes because a list is not the same object as True.
I add an assertion for
bool(a_list)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause the result of
bool([0, 1, 2, 'n'])is True.I change assertFalse to assertTrue for
(bool(a_list))the test passes.
I add a comment
I add an assertion for
a_listwithout boolthe terminal is my friend, and shows AssertionError
AssertionError: [0, 1, 2, 'n'] is not falsebecause the result of
bool([0, 1, 2, 'n'])is True.I change assertFalse to assertTrue for
a_listI remove the commented lines from test_is_a_list_falsy_or_truthy
The empty list is grouped as False. A list with things is grouped as True.
test_is_a_set_falsy_or_truthy
Is a set grouped as False or True?
RED: make it fail
I go back to the terminal where the tests are running
I add a test for if a set (anything in curly braces that is not key-value pairs
{ }) is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: set() != False
GREEN: make it pass
I change assertEqual to assertNotEqual for set(), False
136 self.assertTrue(a_list)
137
138 def test_is_a_set_falsy_or_truthy(self):
139 # self.assertEqual(set(), False)
140 self.assertNotEqual(set(), False)
141
142
143# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if the empty set is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: set() is not FalseI change assertIs to assertIsNot for
set(), Falsethe test passes because a set is not the same object as False.
I add an assertion for if the empty set is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: set() != TrueI change assertEqual to assertNotEqual for
set(), Truethe test passes.
I add an assertion for if the empty set is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: set() is not TrueI change assertIs to assertIsNot for
set(), Truethe test passes because a set is not the same object as True.
I add an assertion for
bool(set())the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(set())is False.I change assertTrue to assertFalse for
bool(set())the test passes.
I add a comment
I add an assertion for
set()without boolthe terminal is my friend, and shows AssertionError
AssertionError: set() is not truebecause the result of
bool(set())is False.I change assertTrue to assertFalse for
set()I remove the commented lines from test_is_a_set_falsy_or_truthy
I add an assertion to test if a set with things is grouped as False or True
the terminal is my friend, and shows AssertionError
AssertionError: {0, 1, 2, 'n'} != FalseI change assertEqual to assertNotEqual for
a_set, Falsethe test passes.
I add an assertion for if a set with things is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: {0, 1, 2, 'n'} is not FalseI change assertIs to assertIsNot for
a_set, Falsethe test passes because a set is not the same object as False.
I add an assertion to test if a set with things is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: {0, 1, 2, 'n'} != TrueI change assertEqual to assertNotEqual for
a_set, Truethe test passes.
I add an assertion for if a set with things is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: {0, 1, 2, 'n'} is not TrueI change assertIs to assertIsNot for
a_set, Truethe test passes because a set is not the same object as True.
I add an assertion for
bool(a_set)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause the result of
bool({0, 1, 2, 'n'})is True.I change assertFalse to assertTrue for
(bool(a_set))the test passes.
I add a comment
I add an assertion for
a_setwithout boolthe terminal is my friend, and shows AssertionError
AssertionError: {0, 1, 2, 'n'} is not falsebecause the result of
bool({0, 1, 2, 'n'})is True.I change assertFalse to assertTrue for
a_setI remove the commented lines from test_is_a_set_falsy_or_truthy
The empty set is grouped as False. A set with things is grouped as True.
test_is_a_dictionary_falsy_or_truthy
Is a dictionary grouped as False or True?
RED: make it fail
I go back to the terminal where the tests are running
I add a test for if a dictionary (key-value pairs separated by commas in curly braces
{ }) is grouped as False or Truethe terminal is my friend, and shows AssertionError
AssertionError: {} != Falsethe empty dictionary is not equal to False
GREEN: make it pass
I change assertEqual to assertNotEqual for dict(), False
152 self.assertTrue(a_set)
153
154 def test_is_a_dictionary_falsy_or_truthy(self):
155 # self.assertEqual(dict(), False)
156 self.assertNotEqual(dict(), False)
157
158
159# NOTES
the test passes.
REFACTOR: make it better
I add an assertion for if the empty dictionary is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: {} is not Falsethe empty dictionary is not the same object as False
I change assertIs to assertIsNot for
dict(), Falsethe test passes because a dictionary is not the same object as False.
I add an assertion for if the empty dictionary is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: {} != Truethe empty dictionary is not equal to True.
I change assertEqual to assertNotEqual for
dict(), Truethe test passes.
I add an assertion for if the empty dictionary is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: {} is not Truethe empty dictionary is not the same object as True
I change assertIs to assertIsNot for
dict(), Truethe test passes because a dictionary is not the same object as True.
I add an assertion for
bool(dict())the terminal is my friend, and shows AssertionError
AssertionError: False is not truebecause the result of
bool(dict())is False.I change assertTrue to assertFalse for
bool(dict())the test passes.
I add a comment
I add an assertion for
dict()without boolthe terminal is my friend, and shows AssertionError
AssertionError: {} is not truebecause the result of
bool(dict())which isbool({})is False.dict()is another way to write{}(the empty dictionary).
I change assertTrue to assertFalse for
dict()The test passes because the result of
bool(dict())is False.The empty dictionary is grouped as False.
I remove the commented lines from test_is_a_dictionary_falsy_or_truthy
I add an assertion to test if a dictionary with things is grouped as False or True
the terminal is my friend, and shows AssertionError
AssertionError: {'key': 'value'} != FalseI change assertEqual to assertNotEqual for
a_dictionary, Falsethe test passes.
I add an assertion for if a dictionary with things is the same object as False
the terminal is my friend, and shows AssertionError
AssertionError: {'key': 'value'} is not FalseI change assertIs to assertIsNot for
a_dictionary, Falsethe test passes because a dictionary is not the same object as False.
I add an assertion to test if a dictionary with things is equal to True
the terminal is my friend, and shows AssertionError
AssertionError: {'key': 'value'} != TrueI change assertEqual to assertNotEqual for
a_dictionary, Truethe test passes.
I add an assertion for if a dictionary with things is the same object as True
the terminal is my friend, and shows AssertionError
AssertionError: {'key': 'value'} is not TrueI change assertIs to assertIsNot for
a_dictionary, Truethe test passes because a dictionary is not the same object as True.
I add an assertion for
bool(a_dictionary)the terminal is my friend, and shows AssertionError
AssertionError: True is not falsebecause the result of
bool({'key': 'value'})is True.I change assertFalse to assertTrue for
(bool(a_dictionary))the test passes.
I add a comment
I add an assertion for
a_dictionarywithout boolthe terminal is my friend, and shows AssertionError
AssertionError: {'key': 'value'} is not falsebecause the result of
bool({'key': 'value'})is True.I change assertFalse to assertTrue for
a_dictionaryThe test passes because the result of
bool({'key': 'value'})is True.A dictionary with things is grouped as True.
I remove the commented lines from test_is_a_dictionary_falsy_or_truthy
The empty dictionary is grouped as False. A dictionary with things is grouped as True.
extract assert_is_falsy method
All the objects had the same assertions when testing if something is grouped as False
self.assertNotEqual(an_object, False)
self.assertIsNot(an_object, False)
self.assertNotEqual(an_object, True)
self.assertIsNot(an_object, True)
self.assertFalse(bool(an_object))
self.assertFalse(an_object)
I can make a function to remove the repetition.
RED: make it fail
I go back to the terminal where the tests are running
I use the assert_is_falsy method in test_is_none_falsy_or_truthy
the terminal is my friend, and shows AssertionError
AssertionError: None != False
GREEN: make it pass
I change assertEqual to assertNotEqual for
an_object, Falsein the assert_is_falsy methodthe terminal is my friend, and shows AssertionError
AssertionError: None is not FalseI change assertIs to assertIsNot for
an_object, Falsethe terminal is my friend, and shows AssertionError
AssertionError: None != TrueI change assertEqual to assertNotEqual for
an_object, Truethe terminal is my friend, and shows AssertionError
AssertionError: None is not TrueI change assertIs to assertIsNot for
an_object, Truethe terminal is my friend, and shows AssertionError
AssertionError: False is not trueI change assertTrue to assertFalse for
bool(an_object)the terminal is my friend, and shows AssertionError
the test passes. The assert_is_falsy method works.
REFACTOR: make it better
I remove the commented lines from assert_is_falsy
I remove the commented lines from test_is_none_falsy_or_truthy
I use the assert_is_falsy method for
0in test_is_an_integer_falsy_or_truthythe terminal is my friend, and shows AssertionError
AssertionError: 0 == Falsebecause the value of False is
0.I remove the call to the assert_is_falsy method because I cannot it use it for
0the test is green again.
I use the assert_is_falsy method for
0.0in test_is_a_float_falsy_or_truthythe terminal is my friend, and shows AssertionError
AssertionError: 0.0 == Falsebecause the value of False is
0which is equal to0.0.I remove the call to the assert_is_falsy method because I cannot it use it for
0.0green again.
I add a comment about the value of False
I use the assert_is_falsy method for the empty dictionary in test_is_a_dictionary_falsy_or_truthy
the test is still green.
I remove the commented lines from test_is_a_dictionary_falsy_or_truthy
I use the assert_is_falsy method for the empty set in test_is_a_set_falsy_or_truthy
still green.
I remove the commented lines from test_is_a_set_falsy_or_truthy
I use the assert_is_falsy method for the empty list in test_is_a_list_falsy_or_truthy
still green.
I remove the commented lines from test_is_a_list_falsy_or_truthy
I use the assert_is_falsy method for the empty tuple in test_is_a_tuple_falsy_or_truthy
green.
I remove the commented lines from test_is_a_tuple_falsy_or_truthy
I use the assert_is_falsy method for the empty string in test_is_a_string_falsy_or_truthy
green.
I remove the commented lines from test_is_a_string_falsy_or_truthy
extract assert_is_truthy method
All the objects had the same assertions when testing if something is grouped as True
self.assertNotEqual(an_object, False)
self.assertIsNot(an_object, False)
self.assertNotEqual(an_object, True)
self.assertIsNot(an_object, True)
self.assertTrue(bool(an_object))
self.assertTrue(an_object)
I can make a method like I did with :ref:`assert_is_falsy<extract assert_is_falsy method>`to remove the repetition.
RED: make it fail
I go back to the terminal where the tests are running
I use the assert_is_truthy method for a negative integer in test_is_an_integer_falsy_or_truthy
the terminal is my friend, and shows AssertionError
AssertionError: -1 != False
GREEN: make it pass
I change assertEqual to assertNotEqual for
an_object, Falsein the assert_is_truthy methodthe terminal is my friend, and shows AssertionError
AssertionError: -1 is not FalseI change assertIs to assertIsNot for
an_object, FalseAssertionError: -1 != TrueI change assertEqual to assertNotEqual for
an_object, Truethe terminal is my friend, and shows AssertionError
AssertionError: -1 is not TrueI change assertIs to assertIsNot for
an_object, Truethe terminal is my friend, and shows AssertionError
AssertionError: True is not falseI change assertFalse to assertTrue for
bool(an_object)the terminal is my friend, and shows AssertionError
AssertionError: -1 is not falseI change assertFalse to assertTrue for
an_objectthe test passes, the assert_is_truthy method works as expected.
REFACTOR: make it better
I remove the commented lines from assert_is_truthy
I remove the commented lines from test_is_an_integer_falsy_or_truthy
I use the assert_is_truthy method for a positive integer
the terminal is my friend, and shows AssertionError
AssertionError: 1 == Truebecause the value of True is
1.I remove the call to the assert_is_truthy method because I cannot it use it for
1the test is green again.
I add a comment about the value of True
I use the assert_is_truthy method for a dictionary with things in test_is_a_dictionary_falsy_or_truthy
the test is still green.
I remove the commented lines from test_is_a_dictionary_falsy_or_truthy
I use the assert_is_truthy method for a set with things in test_is_a_set_falsy_or_truthy
still green.
I remove the commented lines from test_is_a_set_falsy_or_truthy
I use the assert_is_truthy method for a list with things in test_is_a_list_falsy_or_truthy
green.
I remove the commented lines from test_is_a_list_falsy_or_truthy
I use the assert_is_truthy method for a tuple with things in test_is_a_tuple_falsy_or_truthy
still green.
I remove the commented lines from test_is_a_tuple_falsy_or_truthy
I use the assert_is_truthy method for a string with things in test_is_a_string_falsy_or_truthy
the test is still green.
I remove the commented lines from test_is_a_string_falsy_or_truthy
I use the assert_is_truthy method for a positive float in test_is_a_float_falsy_or_truthy
still green.
I use the assert_is_truthy method for a negative float
green.
I remove the commented lines from test_is_a_float_falsy_or_truthy
extract assert_is_not_the_same_as_false_or_true method
The assert_is_falsy and assert_is_truthy methods use the same assertion to make sure that the object they receive is not the same as False or True.
self.assertNotEqual(an_object, False)
self.assertIsNot(an_object, False)
self.assertNotEqual(an_object, True)
self.assertIsNot(an_object, True)
I can add a method to remove this repetition.
REFACTOR: make it better
I go back to the terminal where the tests are running
I add a method named assert_is_not_the_same_as_false_or_true
I use the assert_is_not_the_same_as_false_or_true method in assert_is_falsy
the tests are still green.
I remove the commented lines from assert_is_falsy
I use the assert_is_not_the_same_as_false_or_true method in assert_is_truthy
the tests are still green.
I remove the commented lines from assert_is_truthy
In Python the value of True is 1.
close the project
I close
test_booleans.pyI click in the terminal where the tests are running
I use q on the keyboard to leave the tests. The terminal goes back to the command line.
I change directory to the parent of
booleansthe terminal shows
.../pumping_python
review
I know that bool is an object. It only has two instances - False and True
In Python the following objects are grouped as
The following things are grouped as False
The following things are grouped as True
containers with things
positive and negative numbers
This comes in handy when I want programs to make decisions, because they can choose what to do based on if an object is grouped as False (0, empty or None ) or is grouped as True (positive and negative numbers or has something in it).
I can use assertFalse in place of assertIs(bool(x), False) and assertTrue for assertIs(bool(x), True).
How many questions can you answer after going through this chapter?
code from the chapter
what is next?
So far I have done the same steps to make a Python Test Driven Development environment. Would you like to see me turn those steps into a program to automatically make a Test Driven Development project with one command?.
rate pumping python
If this has been a 7 star experience for you, please CLICK HERE to leave a 5 star review of pumping python. It helps other people get into the book too.