Topic: Open Source

Python Projects (111890866X) cover image

Python Projects

Laura Cassell, Alan Gauld
ISBN: 978-1-118-90866-2
Paperback
384 pages
December 2014
Other Available Formats: Wiley E-Text
If you are an instructor, you may request an evaluation copy for this title.
Paperback Version: US $45.00 Add to Cart

Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
1 7 Error in Text
last paragraph on the page
Currently Reads:
Python requires that literal strings be enclosed within quotation marks. Python is extremely flexible in this regard and accepts single quotes (‘Joe’), double quotes (“Joe”), triple quotes (‘‘‘Joe’’’), and triple double quotes (“““Joe”””), to delimit a string.
Should Read:
Python requires that literal strings be enclosed within quotation marks. Python is extremely flexible in this regard and accepts single quotes ('Joe'), double quotes ("Joe"), triple quotes ('''Joe'''), and triple double quotes ("""Joe""") to delimit a string.
16 July 2015
1 19 Error in Code
code at the bottom of the page
Currently Reads:
result = []
for n in range(1,11):
     if n*n % 2:
        result.append(n)
Should Read:
result = []
for n in range(1,11):
      if not n*n % 2:
          result.append(n)
17 July 2015
1 31 Error in Code
In step 5
c2 = Circle2(42)
should read
c2 = tc.Circle2(42)
14/Aug/2015
37 Text Correction: Error in Code
The bit() function definition in bits.py, on page 37, should read:
def bit(val,idx):
mask = 1 << idx # all 0 except idx
return bool(val & mask)
04/02/15
41 Text Correction: Error in Code
Point 6
Currently reads:
Create a new empty __init.py__ file.
Should Read:
Create a new empty __init__.py file.
01/07/14
2 85 Error in Code
at the top, in the code for step 5
Currently reads
>>> conf['Anne']['lending_period']
Should be followed by an additional line with '30' as such:
>>> conf['Anne']['lending_period']
'30'
14/Aug/2015
3 147 Text Correction: Error in Code
Chapter 3, page 147: the end of the code on this page, the 4th to last line is incorrectly indented and should be indented as follows:
owners = ('Fred','Mike','Joe','Rob','Anne','Fred')
for item in cur.execute("select id from item").fetchall():
itemID = item[0]
cur.execute(set_owner_sql, (owners[itemID-1], itemID))
cur.close()
db.commit()
db.close
04/02/15
151 Text Correction: Error in Code
On page 151, the initDB() function should read:
def initDB(filename = None):
global db, cursor
if not filename:
filename = 'lendy.db'
try:
db = sql.connect(filename)
cursor = db.cursor()
cursor.execute('PRAGMA Foreign_Keys=True')
#### THIS LINE IS MISSING ###
except:
print("Error connecting to", filename)
cursor = None
raise
04/02/15
5 251 Error in Code
Currently reads:
class TCPHandler(socketserver.BaseRequestHandler):
def handle(self):
self.data = self.request.recv(1024).strip()
print("{} wrote:".format(self.client_address[0]))
print(self.data)
# just send back the same data, but upper‐cased
self.request.sendall(self.data.upper())
Should Read:
class TCPHandler(socketserver.BaseRequestHandler):
def handle(self):
self.data = self.request.recv(1024).strip()
print("{} wrote:".format(self.client_address[0]))
print(self.data)
# just send back the same data, but upper‐cased
self.request.sendall(self.data.upper())
8 July 2015
6 263 Error in Code
(first code segment)
Currently reads:
import unittest
class PythonProjectsTest(unittest.TestCase):
eturn

Should Read:
import unittest
class PythonProjectsTest(unittest.TestCase):
pass
26 June 2015
6 263 Error in Code
(second code segment)
Currently Reads:
import unittest
class PythonProjectsTest(unittest.TestCase):
def test_to_fail(self):
self.failIf(False)
if __name__ == '__main__':
unittest.main()

Should Read:
import unittest
class PythonProjectsTest(unittest.TestCase):
def test_to_fail(self):
self.failIf(True)
if __name__ == '__main__':
unittest.main()

26 June 2015
6 263 Error in Text
(paragraph under second)
Currently reads:
In this case, you're passing in False, which will, of course, evaluate to false.
Should read:
In this case, you're passing in True, which will, of course, evaluate to true.
26 June 2015
6 264 Error in Code
(second to last line in last block of code on the page)
Currently Reads:
list_chars = ['m', 'd', 'z', 'l'] import unittest

Should read:
list_chars = ['m', 'd', 'z', 'l']

26 June 2015
Appendix A 303 Error in Code
Solution 3
The first line of code should NOT have parens round the red, orange,....violet
14/Aug/2015
Appendix A 304 Error in Code
solution 3
Currently reads
print('I don't like your color choice')
should say [with double quotes]
print("I don't like your color choice")
14/Aug/2015
Appendix A 304 Error in Code
Solution 7
In the reset() method, the line
if 0 < value < 9:
should read
if 0 <= value <= 9:
14/Aug/2015
1 40 & 41 Errata in Code
Page 40, mid way down

Currently Reads:

   def listbits(self, start=0,end=-1):
       end = end if end < 0 else end+2
       return [int(c) for c in bin(self)[start+2:end]]

Should Read:

   def listbits(self, start=0,end=None):
       if end: end = end if end < 0 else end+2
       return [int(c) for c in bin(self)[start+2:end]]

That's a change on each of lines 1 and 2.

Also the output on page 41, top line should be changed to:

[1, 1, 1, 1, 0, 0, 0, 0]
ie. an extra zero at the end.
23-Dec-15