Welcome to the world of object oriented programming
“self” has only a meaning inside a class. Inside a class “self” is a reference to the class instance itself (hence “self”). Similar to “this” in C++.
To get familiar with classes in Python I suggest reading chapter 9 of the tutorial that comes with Python.
Now for the “accept”. Accept is a method of the class “DirectObject”, one of the many classes Panda3D offers. To use it you must have either an instance of the class DirectObject, or an instance of a class derived from DirectObject.
This would be deriving (your class inherits all the methods of class DirectObject, and among them “accept”):
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
class World( DirectObject ):
def __init__( self ):
self.accept( 'space', self.hello )
def hello( self ):
print 'hello'
o = World( )
run( )
And this using an instance of DirectObject directly: