methods and class methods

2009-03-31 Thread Zach Goscha
I just learned python programming and is wondering how to change a method to
a class method. Also what are the differences between a method and class
method.

Thanks in advance
- Zach (Freshman student in High school)
--
http://mail.python.org/mailman/listinfo/python-list


Problems with code

2009-03-30 Thread Zach Goscha
Hi,

I am trying to call an unbound method (Map.Background) but getting the 
following error:
 TypeError: unbound method background() must be called with Map instance as 
first argument (got nothing instead)

Here is some of the code(not completed) 

Thanks in Advance
- Zach


Code:

class Knight(games.Sprite):
""" A moving knight. """
SWORD_DELAY = 50
sword_wait = 0


def update(self):
""" moving knight based on keys pressed. """

if games.keyboard.is_pressed(games.K_w):
self.y -= 3
self.angle = 0
if games.keyboard.is_pressed(games.K_s):
self.y += 3
self.angle = 180
if games.keyboard.is_pressed(games.K_a):
self.x -= 3
self.angle = 270
if games.keyboard.is_pressed(games.K_d):
self.x += 3
self.angle = 90

if self.top > games.screen.height:
self.bottom = 0

if self.bottom < 0:
self.top = games.screen.height
Map.background()

if self.left > games.screen.width:
self.right = 0

if self.right < 0:
self.left = games.screen.width

class Map(games.Sprite):

def background(self):
new_back = games.load_image("map3.jpg",
transparent = False)
games.screen.background = new_back

--
http://mail.python.org/mailman/listinfo/python-list