Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > BOOK: Python Projects
|
BOOK: Python Projects
This is the forum to discuss the Wrox book Python Projects Laura Cassell, Alan Gauld; ISBN: 978-1-118-90866-2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Python Projects section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2015, 10:30 AM
jc. jc. is offline
Registered User
 
Join Date: Aug 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default P304, Appendix A, Answer 3

The final line reads:

Code:
print('I don't like your color choice')
But this will generate:

Code:
SyntaxError: invalid syntax
It could read:

Code:
print("I don't like your color choice")
Could someone explain how the tuple(?) is accessible within the if/elif chain, as it is not assigned to a variable? I'm presuming it is just witchcraft! Many thanks.
 
Old August 4th, 2015, 03:13 PM
Wrox Author
 
Join Date: Feb 2015
Posts: 25
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
Originally Posted by jc. View Post
The final line reads:

Code:
print('I don't like your color choice')
But this will generate:

Code:
SyntaxError: invalid syntax
You are quite right. It should be double quotes on the outside of the string.

Quote:
Originally Posted by jc. View Post
Could someone explain how the tuple(?) is accessible within the if/elif chain, as it is not assigned to a variable? I'm presuming it is just witchcraft! Many thanks.
Hmm, I messed this one up didn't I?
The problem is that the first line should not have parens around the
variable names.

it should look more like

red,blue,green = range(3) # no parens.

If you'd asked this question last week I could have consulted the original source
code but sadly, while upgrading to Windows10 at the weekend, I managed to
wipe the drive with all the book source code! But certainly the code in
the manuscript includes parens. My bad!

sorry,

Alan G.
 
Old August 4th, 2015, 04:10 PM
jc. jc. is offline
Registered User
 
Join Date: Aug 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for another quick response Alan and for clearing up my confusion. Please don't get the impression that I dislike the book.

I think it was brave of you to adopt Win10 so early, though it could of been worse...

()

I have the upgrade in the wings for my wife's PC, but my own machine will be sticking with CentOS.
 
Old August 4th, 2015, 04:11 PM
jc. jc. is offline
Registered User
 
Join Date: Aug 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My URL didn't post, trying again, but probably the topic is causing the problem...

http://www.dailymail.co.uk/sciencete...ow-repeat.html
 
Old August 4th, 2015, 06:05 PM
Wrox Author
 
Join Date: Feb 2015
Posts: 25
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
Originally Posted by jc. View Post
I think it was brave of you to adopt Win10 so early, though it could of been worse...
Not that brave, I have 3 PCs. My main one is Linux(Mint), I also have a
Windows XP box(!) and a Windows 8.1 box. I need them for testing/upgrading
old bits of software and new Windows applications respectively.

Its only the 8.1 that got upgraded, but that's the one I used to write the
code for the book. :-(

Alan G.
 
Old August 5th, 2015, 03:52 AM
jc. jc. is offline
Registered User
 
Join Date: Aug 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well that XP box might yet outlive your Win10 box. Mint, phew!





Similar Threads
Thread Thread Starter Forum Replies Last Post
A New Appendix B DanM BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 12 August 14th, 2010 04:53 AM
New Appendix B damonuk BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 July 27th, 2010 04:52 AM
Chapter 9 - Validating user Imput (p304) SouthendSupporter BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 March 9th, 2010 05:24 AM
Appendix A john_tempest BOOK: Professional C# 2005 with .NET 3.0 ISBN: 978-0-470-12472-7 1 August 27th, 2007 06:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.