;Advance Praise for Head First Python;Praise for other Head First books;Author of Head First Python;How to use This Book: Intro; Who is this book for?; We know what you''re thinking; We know what your brain is thinking; Metacognition: thinking about thinking; Here''s what WE did; Here''s what YOU can do to bend your brain into submission; Read Me; The technical review team; Acknowledgments; SafariĀ® Books Online;Chapter 1: Meet Python: Everyone loves lists; 1.1 What''s to like about Python?; 1.2 Install Python 3; 1.3 Use IDLE to help learn Python; 1.4 Work effectively with IDLE; 1.5 Deal with complex data; 1.6 Create simple Python lists; 1.7 Lists are like arrays; 1.
8 Add more data to your list; 1.9 Work with your list data; 1.10 For loops work with lists of any size; 1.11 Store lists within lists; 1.12 Check a list for a list; 1.13 Complex data is hard to process; 1.14 Handle many levels of nested lists; 1.15 Don''t repeat code; create a function; 1.
16 Create a function in Python; 1.17 Recursion to the rescue!; 1.18 Your Python Toolbox;Chapter 2: Sharing your Code: Modules of functions; 2.1 It''s too good not to share; 2.2 Turn your function into a module; 2.3 Modules are everywhere; 2.4 Comment your code; 2.5 Prepare your distribution; 2.
6 Build your distribution; 2.7 A quick review of your distribution; 2.8 Import a module to use it; 2.9 Python''s modules implement namespaces; 2.10 Register with the PyPI website; 2.11 Upload your code to PyPI; 2.12 Welcome to the PyPI community; 2.13 With success comes responsibility; 2.
14 Life''s full of choices; 2.15 Control behavior with an extra argument; 2.16 Before your write new code, think BIF; 2.17 Python tries its best to run your code; 2.18 Trace your code; 2.19 Work out what''s wrong; 2.20 Update PyPI with your new code; 2.21 You''ve changed your API; 2.
22 Use optional arguments; 2.23 Your module supports both APIs; 2.24 Your API is still not right; 2.25 Your module''s reputation is restored; 2.26 Your Python Toolbox;Chapter 3: Files and Exceptions: Dealing with errors; 3.1 Data is external to your program; 3.2 It''s all lines of text; 3.3 Take a closer look at the data; 3.
4 Know your data; 3.5 Know your methods and ask for help; 3.6 Know your data (better); 3.7 Two very different approaches; 3.8 Add extra logic; 3.9 Handle exceptions; 3.10 Try first, then recover; 3.11 Identify the code to protect; 3.
12 Take a pass on the error; 3.13 What about other errors?; 3.14 Add more error-checking code.; 3.15 .Or add another level of exception handling; 3.16 So, which approach is best?; 3.17 You''re done.
except for one small thing; 3.18 Be specific with your exceptions; 3.19 Your Python Toolbox;Chapter 4: Persistence: Saving data to files; 4.1 Programs produce data; 4.2 Open your file in write mode; 4.3 Files are left open after an exception!; 4.4 Extend try with finally; 4.5 Knowing the type of error is not enough; 4.
6 Use with to work with files; 4.7 Default formats are unsuitable for files; 4.8 Why not modify print_lol()?; 4.9 Pickle your data; 4.10 Save with dump and restore with load; 4.11 Generic file I/O with pickle is the way to go!; 4.12 Your Python Toolbox;Chapter 5: Comprehending data: Work that data!; 5.1 Coach Kelly needs your help; 5.
2 Sort in one of two ways; 5.3 The trouble with time; 5.4 Comprehending lists; 5.5 Iterate to remove duplicates; 5.6 Remove duplicates with sets; 5.7 Your Python Toolbox;Chapter 6: Custom data Objects: Bundling code with data; 6.1 Coach Kelly is back (with a new file format); 6.2 Use a dictionary to associate data; 6.
3 Bundle your code and its data in a class; 6.4 Define a class; 6.5 Use class to define classes; 6.6 The importance of self; 6.7 Every method''s first argument is self; 6.8 Inherit from Python''s built-in list; 6.9 Coach Kelly is impressed; 6.10 Your Python Toolbox;Chapter 7: Web Development: Putting it all together; 7.
1 It''s good to share; 7.2 You can put your program on the Web; 7.3 What does your webapp need to do?; 7.4 Design your webapp with MVC; 7.5 Model your data; 7.6 View your interface; 7.7 Control your code; 7.8 CGI lets your web server run programs; 7.
9 Display the list of athletes; 7.10 The dreaded 404 error!; 7.11 Create another CGI script; 7.12 Enable CGI tracking to help with errors; 7.13 A small change can make all the difference; 7.14 Your webapp''s a hit!; 7.15 Your Python Toolbox;Chapter 8: Mobile app Development: Small devices; 8.1 The world is getting smaller; 8.
2 Coach Kelly is on Android; 8.3 Don''t worry about Python 2; 8.4 Set up your development environment; 8.5 Configure the SDK and emulator; 8.6 Install and configure Android Scripting; 8.7 Add Python to your SL4A installation; 8.8 Test Python on Android; 8.9 Define your app''s requirements; 8.
10 The SL4A Android API; 8.11 Select from a list on Android; 8.12 The athlete''s data CGI script; 8.13 The data appears to have changed type; 8.14 JSON can''t handle your custom datatypes; 8.15 Run your app on a real phone; 8.16 Configure AndFTP; 8.17 The coach is thrilled with his app; 8.
18 Your Python Toolbox;Chapter 9: Manage Your data: Handling input; 9.1 Your athlete times app has gone national; 9.2 Use a form or dialog to accept input; 9.3 Create an HTML form template; 9.4 The data is delivered to your CGI script; 9.5 Ask for input on your Android phone; 9.6 It''s time to update your server data; 9.7 Avoid race conditions; 9.
8 You need a better data storage mechanism; 9.9 Use a database management system; 9.10 Python includes SQLite; 9.11 Exploit Python''s database API; 9.12 The database API as Python code; 9.13 A little database design goes a long way; 9.14 Define your database schema; 9.15 What does the data look like?; 9.
16 Transfer the data from your pickle to SQLite; 9.17 What ID is assigned to which athlete?; 9.18 Insert your timing data; 9.19 SQLite data management tools; 9.20 Integrate SQLite with your existing webapp; 9.21 You still need the list of names; 9.22 Get an athlete''s details based on ID; 9.23 You need to amend your Android app, too; 9.
24 Update your SQLite-based athlete data; 9.25 The NUAC is over the moon!; 9.26 Your Python Toolbox;Chapter 10: Scaling your Webapp: Getting real; 10.1 There are whale sightings everywhere; 10.2 The HFWWG needs to automate; 10.3 Build your webapp with Google App Engine; 10.4 Download and install App Engine; 10.5 Make sure App Engine is working; 10.
6 App Engine uses the MVC pattern; 10.7 Model your data with App Engine; 10.8 What good is a model without a view?; 10.9 Use templates in App Engine; 10.10 Django''s form validation framework; 10.11 Check your form; 10.12 Controlling your App Engine webapp; 10.13 Restrict input by providing options; 10.
14 Meet the "blank screen of death"; 10.15 Process the POST within your webapp; 10.16 Put your data in the datastore; 10.17 Don''t break the "robustness principle"; 10.18 Accept almost any date and time; 10.19 It looks like you''re not quite done yet; 10.20 Sometimes, the tiniest change can make all the difference.; 10.
21 Capture your user''s Google ID, too; 10.22 Deploy your webapp to Google''s cloud; 10.23 Your HFWWG webapp is deployed!; 10.24 Your Python Toolbox;Chapter 11: Dealing with Complexity: Data wrangling; 11.1 What''s a good time goal for the next race?; 11.2 So. what''s the problem?; 11.3 Start with the data; 11.
4 Store each time as a dictionary; 11.5 Dissect the prediction code; 11.6 Get input from your user; 11.7 Getting input raises an issue.; 11.8 If it''s not in the dictionary, it can''t be found; 11.9 Search for the closest match; 11.10 The trouble is with time; 11.
11 The time-to-seconds-to-time module; 11.12 The trouble is still with time.; 11.13 Port to Android; 11.14 Your Android app is a bunch of dialogs; 11.15 Put your app together.; 11.16 Your app''s a wrap!; 11.
17 Your Python Toolbox; 11.18 It''s time to go.;Leftovers: The Top Ten Things (we didn''t cover); #1: Using a "professional" IDE; #2: Coping with scoping; #3: Testing; #4: Advanced language features; #5: Regular expressions; #6: More on web frameworks; #7: Object relational mappers and NoSQL; #8: Programming GUIs; #9: Stuff to avoid; #10: Other books;.