[an error occurred while processing this directive]
This assignment is intended to give you a chance to demonstrate that you know how to step through code and verfiy code execution. Use the method described in Chapter 4 from Writing Solid Code.
tar -xvf
pymine.tar
).MineField.populate
in the debugger (this method is called every
time you start a new game, after selecting the field size). Follow the guidelines from Writing Solid
Code chapter 4 on how to do this. Check variable values and other state information before and after
execution of each line and verify that the line did what it should. Be sure to step through all
the lines of code, even if that means fixing some of the errors as you go along. (It is only necessary to
step through the populate function and not the subfunctions called by it.)The rubric for this assignment is available here.
You can use pdb within TurboGears. To do so, open up the start-....py file used to run the project and add the following lines of code right before the last line which starts the server:
import pdb cherrypy.config.update({'autoreload.on': False}) pdb.set_trace()
This does a couple things. First, it loads pdb. Second, it disables auto-detection of changes to files while the server is running - without this, if you change a file, the server will restart but the debugger won't quite work... Finally the set_trace() gives you an initial pdb prompt from which you can set breakpoints in your code. For example, setting a breakpoint in the TurboGears wiki tutorial code:
[colin@sliver:~/Desktop/wiki20]$ python start-wiki20.py > /home/colin/Desktop/wiki20/start-wiki20.py(32)() -> turbogears.start_server(Root()) (Pdb) b wiki20/controllers.py:25 Breakpoint 1 at /home/colin/Desktop/wiki20/wiki20/controllers.py:25 (Pdb)
Try it out now if you have time!