Render giving off a werid error

As mentioned numerous times before, I have programmed in many other languages, but I’m new to python. I’ve used other OOP languages before, but I’m not 100% sure on how python’s is supposed to work… That being said this is my code.

import direct.directbase.DirectStart
from direct.actor.Actor import Actor

class Cars(Actor):
	def add(self):
		self.reparentTo(render)#Line 6
		self.top_speed=getTopSpeed()
		self.acceleration=getAcceleration()
	def getTopSpeed(self):
		return 120
	def getAcceleration(self):
		return 20

class Taxi(Cars):
	def __init__(self):
		self=Actor("racingmodels/us_taxi")
	def getTopSpeed(self):
		return 150
	def getAcceleration(self):
		return 17

taxi = Taxi()
taxi.add()#Line 23
run()

The command line gives the error

At line 6 you just have “self.reparentTo(render)” but you have no model to reparen it to the render… aka you’ll need something like… “self.base.camera.reparentTo(render)” to get it to work. Base.camera is your model/node.

Note that your class inherits (indirectly) from NodePath, but then defines its own constructor and doesn’t (properly) call up to the parent constructor. This means your base NodePath class was never initialized, which is what is triggering this particular error message.

When you define a constructor, you should generally always call up to the base class constructor, something like this:

   def __init__(self):
      Cars.__init__("racingmodels/us_taxi") 

Note also that assigning self does nothing. It doesn’t change the instance to a new Actor.

David

Im not exactly sure on how this works. taxi=Taxi() doesn’t create a new actor? and I have to call the parent’s init function manually?

This might just be the worst OOP language ever. :O.

Can someone show me the orthodox method of doing what I’m doing?

[edit]

What does this message mean?

[Edit 2]
This code got it work

import direct.directbase.DirectStart
from direct.actor.Actor import Actor

class Cars(Actor):
	def __init__(self,stance):
		self.base=Actor(stance,{"stance":stance})
	def add(self):
		self.base.reparentTo(render)
		self.base.top_speed=self.getTopSpeed()
		self.base.acceleration=self.getAcceleration()
	def getTopSpeed(self):
		return 120
	def getAcceleration(self):
		return 20

class Taxi(Cars):
	def __init__(self):
		Cars.__init__(self,"racingmodels/us_taxi")
	def getTopSpeed(self):
		return 150
	def getAcceleration(self):
		return 17

taxi = Taxi()
taxi.add()
print taxi.base.top_speed
run()

Found this post

discourse.panda3d.org/viewtopic.php?t=6714

And I went through and deleted all the blend’s and it fixes that little, not a character bug.