Wednesday, September 23, 2009

Chapter 9 Exercise 9.34

The rule F ->

means that F can be replaced by nothing.

Chapter 9 Listing 9.7

when setposition is called to restore the turtle's position and heading to a previously stored location, the tail should be up. so Lines 16 and following should read:


elif cmd == ']':
pos,head = stateSaver.pop()
aTurtle.up()
aTurtle.setposition(pos)
aTurtle.setheading(head)
aTurtle.down()

Chapter 5 page 174

On Line 9 the sentence should read

Without this call to readline, line would have no value. The book incorrectly states that read would have no value.

Chapter 3 Session 3.4

The last expression of Session 3.4 should be name[len(name)-1] not name[len(name)]. name[len(name)] generates a range error because the length of the string is 1 past the end of the string.

Friday, September 18, 2009

Chapter 2 -- Page 81 -- Problems 2.2,2.3,2.4

The problems say to use a parameter called n. It probably makes more sense to use r or perhaps radius.

Chapter 2 -- Page 81 -- Problem 2.5

The equation given in this problem is missing constants. It should read:

16 arctan(1/5) - 4 arctan(1/239)

Monday, September 7, 2009

Hanging Turtles

If you are using idle, some of the initial interactive examples will appear to hang. That is, if the turtle window gets behind another window its impossible to bring it to the front, and/or the window does not get refreshed. This is due to some weird threading interactions between the IDLE GUI and the shell. The problems are frustrating when you run into them in the first chapter. However as you write programs longer than 4 or 5 lines that include the exitOnClick call, they disappear quickly. A couple of suggestions to avoid this initial frustration:

  • Run these first examples from the command line shell. e.g. just type python3.1

  • Run idle using -n command line option. Windows and OS X can also be configured to start idle with -n

  • Carefully setup your idle shell and the turtle window so they are side by side with no other windows to distract.