Cant figure the problem!!!!!

Hi every1, i have a strange problem with the following code+ error:

The code:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
class World(DirectObject):
def init(self):

 base.setBackgroundColor(0, 0, 0)
 self.track = loader.loadModel("../Models/Track.egg")
 self.track.reparentTo(render)
 self.track.setPos(0,0,-5)
 self.cycle=loader.loadModel("../Models/Ref.egg")
 self.cycle.reparentTo(render)
 self.cycle.setPos(2,15,0)
 dt = globalClock.getDt()
 self.keyMap = {"w" : False,
	"s" : False,
	"a" : False,
	"d" : False}
 taskMgr.add(self.cycleControl, "Cycle Control")
 taskMgr.doMethodLater(10, self.debugTask, "Debug Task")
 self.accept("w", self.setKey, ["w", True])
 self.accept("s", self.setKey, ["s", True])
 self.accept("a", self.setKey, ["a", True])
 self.accept("d", self.setKey, ["d", True])
 self.accept("w-up", self.setKey, ["w", False])
 self.accept("s-up", self.setKey, ["s", False])
 self.accept("a-up", self.setKey, ["a", False])
 self.accept("d-up", self.setKey, ["d", False])
 
 def setKey(self, key, value):
	self.keyMap[key] = value
 
def cycleControl(self, task):
	dt = globalClock.getDt()
	if( dt > .20):
		return task.cont
	if(self.keyMap["w"] == True):
		self.cycle.setY(self.cycle, 10 * dt)
	return task.cont
	
def debugTask(self, task):
	print(taskMgr)
	taskMgr.removeTasksMatching("Cycle Move *")
	return task.again

w=World()
run()

The error i get when i run it:
File “chp04_02.py”, line 20, in init
self.accept(“w”, self.setKey, [“w”, True])
AttributeError: World instance has no attribute ‘setKey’

Why?.. i declared it! … i really dont get it…

The most likely reason is the setKey method is (due to indentation) not actually a part of the World class, but since it looks like indentation was messed up when you pasted your code, I’m not 100% certain. Could you please paste your code inside BBCode code tags, so indentation is preserved?

Got it… you were right, i looked very carefully over my code again, and def setKey had 1 space in front of it and was out of line with the other def’s … deleted the space and now it works … thx again DangeronTheRanger!