is it possible to derive from Actor.Actor?

I wanted to use derivation for my characters, like this:

class MyActor(Actor.Actor):
   def __init__(self):
      super(MyActor, self).__init__("modelfile", {"anim1", "anim1file"})
      self.velocity = 0 = 100

but it gives me this error:

TypeError: super() argument 1 must be type, not classobj

Is it not possible to derive from Actor.Actor? I could always use composition, I’m just trying to get a feel for what’s possible.

What happen if you replace

 super(MyActor, self).__init__("modelfile", {"anim1", "anim1file"}) 


Actor.Actor.__init__(self,"modelfile", {"anim1", "anim1file"})

ah, then it works. So why doesn’t super() work? Maybe that requires new-style python classes and the panda ones aren’t?

In fact i don’t know if super has the same meaning in Python that it has in java for example.

I’m not good enough at python programming yet…

maybe doing super(Actor.Actor,self).init(“modelfile”, {“anim1”, “anim1file”}) would work also…

super does not work with classes in python 2.2, as far as I know. It does work in python 2.4 however (your example code runs fine in 2.4). Since the new version of panda will be in 2.4, you’ll be able to use super then. However, Actor.Actor.init(self) seems a bit more readable overall

I think you are right that it wouldn’t work in 2.2 but I’m using 2.4 (on ubuntu linux) and it still doesn’t work. I agree that simply calling out the base class seems simpler.

Yeah, this is basically python semantics. So a class that is not instantiated in python is usually a ‘type’ (ie, do a type(obj) and look at the result). If you instantiate it, then you get a ‘class’. This normally isn’t a problem with super, because you are calling it on the non-bound code. However, all panda objects in 1.0.5 are classes uninstanced. You can check this by doing a type(Actor.Actor). Your class is inheriting the type ‘class’, and then bails because super only works on python types (<type ‘type’>).

The good news is that the new version of panda is making all panda objects have the type ‘type’. The end result is that they work exactly like normal python types, and as such super(myActor) should work fine.