I'm using the following tutorial to learn Python: How to think like a computer scientist

I'm running the following code and I get an error:

from gasp import *


begin_graphics(800, 600, title="Catch", background=color.yellow)
set_speed(120)

ball_x = 10
ball_y = 300
ball = Circle((ball_x, ball_y), 10, filled=True)
dx = 4
dy = 1

while ball_x < 810:
    ball_x += dx
    ball_y += dy
    move_to(ball, (ball_x, ball_y))
    update_when('next_tick')

end_graphics()

I get the following error when Attempting to run the code:

Traceback (most recent call last):
File "C:/Documents and Settings/zodkoyj/Desktop/Python/pitch.py", line 6, in <module>
set_speed(120)
NameError: name 'set_speed' is not defined

From everything I can find it should be part of the GASP module, but it doesn't appear to be. In the example code located HERE all I need to import is GASP. Any suggestions on where I can find the set_speed definition? Any help would be appreciated.

To find all functions/methods in a module like gasp use:

import gasp
print "List the functions within module gasp:"
for f in dir(gasp):
    print f

Look at the output, maybe it's just a minor spelling difference.

Info:
GASP (Graphics API for Students of Python) is a library built on pygame that enables absolute beginners to write 1980's style arcade games as an introduction to python

It doesn't appear to be in the list

Arc
Box
Circle
Image
Line
Oval
Plot
Point
Polygon
Screen
Shape
Sound
Text
__builtins__
__doc__
__file__
__name__
__path__
api
backend
begin_graphics
clear_screen
color
create_sound
end_graphics
key_pressed
keys_pressed
make_it_a_point
math
mouse_buttons
mouse_position
move_by
move_to
pause
play_sound
random
random_between
random_choice
read_number
read_string
read_yesorno
remove_from_screen
rotate_by
rotate_to
screen_shot
sleep
stop_sound

There are other functions missing too, like update_when(). Where did you get the code sample from? Maybe you have an outdated version of gasp.

There are other functions missing too, like update_when(). Where did you get the code sample from? Maybe you have an outdated version of gasp.

I downloaded the source from this site: http://dev.laptop.org/pub/gasp/downloads/

They say the installer for windows is out of date so I should download the source.

Interested in gasp?
See the post at:
http://www.daniweb.com/forums/post606877-137.html

Also take a look at the post from vegaseat on pygame just above that one.

Note: The missing function set_speed() sounds like something that would use pygame's clock() function. I heard the newer vesion 0.2.0 of gasp has incorporated clock().

Awesome. Thank you! the 0.2.0 beta works. I appreciate the help.

Awesome. Thank you! the 0.2.0 beta works. I appreciate the help.

I am glad it works now. Where did you download the new beta version from?

Im following that same tutorial. If i use the stable version of gasp 0.1.1, i get those same errors of course( the missing elements of the module)
If i use the beta, 0.2.0, it of course includes the missing things. begin_graphics() works, and whatever i specify is drawn to the screen, but once you try to do anything like capture an input or even end_graphics(), python locks up. does this happen for anyone else?

ps. you can download any of the versions at
https://launchpad.net/gasp-code/+download

This question has already been answered. Start a new discussion instead.