Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > BOOK: Python Projects
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2015, 10:30 AM
jc. jc. is offline
Registered User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #2 (permalink)  
Old August 4th, 2015, 03:13 PM
Wrox Author
Points: 119, Level: 2
Points: 119, Level: 2 Points: 119, Level: 2 Points: 119, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2015
Location: Stirling, Scotland
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.
Reply With Quote
  #3 (permalink)  
Old August 4th, 2015, 04:10 PM
jc. jc. is offline
Registered User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #4 (permalink)  
Old August 4th, 2015, 04:11 PM
jc. jc. is offline
Registered User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #5 (permalink)  
Old August 4th, 2015, 06:05 PM
Wrox Author
Points: 119, Level: 2
Points: 119, Level: 2 Points: 119, Level: 2 Points: 119, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2015
Location: Stirling, Scotland
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.
Reply With Quote
  #6 (permalink)  
Old August 5th, 2015, 03:52 AM
jc. jc. is offline
Registered User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.