[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Name self not defined



this is the code in question:

class Car(Basicsprite): #car class
    def __init__(self, speedarg=(0,0)):
        self.speed = speedarg
        Basicsprite.__init__(self)
    def move(self, speedv=self.speed):
        self.rect = self.rect.move(speedv)


however, when I try to import that class from python:



>>> from basicsprite import Car
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "basicsprite.py", line 14, in <module>
    class Car(Basicsprite): #car class    
  File "basicsprite.py", line 18, in Car
    def move(self, speedv=self.speed):
NameError: name 'self' is not defined



how can self not be defined??