Chapter 2. Hunt the Wumpus
Listing 2.1. Your first version of Hunt the Wumpus
Listing 2.2. BANG! Your program explodes
Listing 2.3. Adding a friend for the wumpus
Listing 2.4. Setting up your caves
Listing 2.5. Altering your program to use the new cave system
Listing 2.6. Creating a linked cave network
Listing 2.7. Adding convenience functions
Listing 2.8. Cave-creation functions
Listing 2.9. Player-interaction functions
Listing 2.10. The refactored wumpus game
Listing 2.12. An interface for Hunt the Wumpus
Chapter 3. Interacting with the world
Listing 3.1. Finding out more about the os.path library
Listing 3.2. Reading parameters using sys
Listing 3.4. Generating a hash for a file
Listing 3.5. How to use a dictionary
Listing 3.6. Utility functions for your difference program
Listing 3.7. Finding the differences between directories
Chapter 4. Getting organized
Listing 4.1. Your first unit test
Listing 4.2. One part of the program you can’t test
Listing 4.3. The other part of the program you can’t test
Listing 4.4. Finding command fields
Listing 4.5. Testing run_command
Listing 4.6. Writing run_command
Listing 4.7. Your program so far
Listing 4.8. Testing your to-do list view
Listing 4.9. Displaying to-do items
Listing 4.10. Testing the order of your view
Listing 4.11. Lots of things you can do with list comprehensions
Listing 4.12. Code to sort your list of to-dos
Listing 4.13. Output from your tests
Listing 4.14. A better way to display your to-dos
Listing 4.15. Testing that your to-dos wrap lines
Listing 4.16. A function to show a to-do
Listing 4.17. Testing that your application saves properly
Listing 4.18. Loading and saving your to-dos
Listing 4.19. Automatic loading and saving
Listing 4.20. Adding a to-do sorter
Listing 4.22. Testing deletion
Listing 4.24. Testing to-do editing
Chapter 5. Business-oriented programming
Listing 5.1. Downloading a web page
Listing 5.2. Finding the quote section
Listing 5.3. Extracting the data for the stock
Listing 5.4. Writing a CSV file
Listing 5.5. Creating a MIME email
Listing 5.7. Queuing email to a temporary file
Listing 5.8. Sending email from a mail queue directory
Listing 5.9. A traceback when sending mail
Listing 5.10. A traceback when parsing an HTML page
Chapter 6. Classes and object-oriented programming
Listing 6.1. An object to store caves
Listing 6.2. A more object-oriented design
Listing 6.4. Running your Player class
Listing 6.5. An object that can be looked at
Listing 6.6. Modifying the look() command
Listing 6.7. Updating your setup
Listing 6.8. Items that will let themselves be picked up
Listing 6.9. Updates to the Player class
Listing 6.10. Adding movement to the Cave class
Listing 6.11. Commands to move between caves
Listing 6.12. Creating a cave network
Listing 6.13. Adding monsters to the game
Chapter 7. Sufficiently advanced technology...
Listing 7.2. Using Python’s logging module
Listing 7.3. Using __getattr__
Listing 7.4. Using __setattr__
Listing 7.5. Using __getattribute__
Listing 7.7. Extending properties
Listing 7.8. Using an iterator the hard way
Listing 7.9. Using your counter generator
Listing 7.10. os.walk revisited
Listing 7.11. The output from os.walk
Listing 7.12. Generators to work through a directory
Listing 7.13. Apache log lines
Chapter 8. Django!
Listing 8.3. A simple todo list
Listing 8.5. A simple template
Listing 8.6. Editing settings.py
Listing 8.8. Adding the todo application to your project
Listing 8.9. Showing your model’s SQL
Listing 8.10. Activating Django’s admin system
Listing 8.11. Registering your model: admin.py
Listing 8.12. Altering your view
Listing 8.13. Readable priorities
Listing 8.14. A RESTful URL design
Listing 8.15. Setting URLs and views
Listing 8.16. A submission form
Listing 8.17. A view to handle adding a todo
Listing 8.18. Updating urls.py
Listing 8.19. A todo editing template
Chapter 9. Gaming with Pyglet
Listing 9.1. Drawing on the screen
Listing 9.4. Updating the ship
Listing 9.7. Figuring out gravity
Chapter 10. Twisted networking
Listing 10.1. A simple chat-server protocol
Listing 10.2. Connecting your protocol
Listing 10.3. Updating your chat protocol
Listing 10.4. Updating your chat Factory
Listing 10.5. Changing your game code to work with the new interface
Listing 10.6. Changing the Player code
Listing 10.9. Updating find_handler
Listing 10.10. Antisocial gaming
Listing 10.12. Twisted’s AuthenticatingTelnetProtocol class
Listing 10.13. RegisteringTelnetProtocol
Chapter 11. Django revisited!
Listing 11.1. Django authentication and login views
Listing 11.3. Adding a field to the database backend
Listing 11.4. Showing only your todos
Listing 11.5. Wrapping the update and delete views
Listing 11.7. Error messages on the index page
Listing 11.8. Unit testing (tests.py)
Listing 11.9. Functional testing
18.223.196.211