My methods not working

Hi,
I am new to Panda3d.I have been working on some tuts.I have discovered that the only code that has any effect are those coming immediately after the class initialization.Once I start defining methods, there is no effect.But if I copy the code and put it under def init(self),it works.Below is an an example code from the Carousel tutorials included in the samples.
/////////////////////////////////////////////////////////////////////////////////////////////

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *
from direct.task import Task
from panda3d.core import NodePath
class World(ShowBase):

def __init__(self):
    ShowBase.__init__(self)
    

    self.title = OnscreenText(text="Panda3D: Tutorial 2 - Carousel",
                          style=1, fg=(1,1,1,1),
                          pos=(0.8,-0.95), scale = .07)
    base.setBackgroundColor(.6, .6, 1) #Set the background color
    base.disableMouse()                #Allow manual positioning of the camera
    camera.setPosHpr( 0, -8, 2.5, 0, -9, 0 )  #Set the cameras' position

    self.carousel = loader.loadModel("models/carousel_base")
    self.carousel.reparentTo(render)
    self.lights1 = loader.loadModel("models/carousel_lights")
    self.lights1.reparentTo(self.carousel)

    self.lights2 = loader.loadModel("models/carousel_lights")
    self.lights2.setH(36)
    self.lights2.reparentTo(self.carousel)

    self.lightsoffTex = loader.loadTexture("models/carousel_lights_off.jpg")
    self.lightsonTex = loader.loadTexture("models/carousel_lights_on.jpg")

    self.pandas = [self.carousel.attachNewNode("panda"+str(i)) for i in range(4)]

    self.models = [loader.loadModel("models/carousel_panda") for i in range(4)]
    self.moves = [0 for i in range(4)]

    for i in range(4):
        self.pandas[i].setPosHpr(0,0,1.3,i*90,0,0)
        self.models[i].reparentTo(self.pandas[i])
        self.models[i].setY(0.85)



    self.env = loader.loadModel("models/env")
    self.env.reparentTo(render)
    self.env.setScale(7)

#Nothing works from here
def setupLights(self):
ambientLight = AmbientLight(“ambientLight”)
ambientLight.setColor(vec4(0.4,0.4,0.35, 1))
directionalLight = DirectionalLight(“directionalLight”)
directionalLight.setColor(vec4(0.9,0.8,0.9,1))
render.setLight(render.attachNewNode(directionalLight))
render.setLight(render.attachNewNode(ambientLight))
self.env.setLightoff()

def startCarousel(self):
    self.carouselSpin = self.carousel.hprInterval(20, vec3(360,0,0))
    self.carouselSpin.loop()

    for i in range(4):
        self.moves[i] = LerpFunc(self.oscilatePanda,
                                 duration = 3,
                                 fromData = 0,
                                 toData = 2 * pi,
                                 extraArgs = [self.models[i], pi*(i%2)]
                                 )
                                 
            
        self.moves[i].loop()

        self.lightBlink = Sequence(
            Parallel(
                Func(self.lights1.setTexture, self.lightOnTex, 1),
                Func(self.lights2.setTexture, self.lightoffTex, 1)),
            wait(1)
            )
        self.lightBlink.loop()                         
     
def oscilatePanda(self, rad, panda, offset):
    panda.setZ(sin(rad + offset) * .2)

w = World()
w.run()
/////////////////////////////////////////////////////////////////////////////////////
What should I do?
Thanks in advance.

Please edit your post and use the code tag.
It makes it easy to just copy/paste and enhances readability.
In python, all spaces are important.

Question. Why do you expect functions to be called,
when your code never calls them?

Example: setupLights.

Hi, welcome to the forums!

Solstice is right; you are defining methods, but never calling them. I would really recommend that you pick up a Python tutorial before beginning with Panda3D so that you get some experience with programming in general; otherwise you’ll get stuck like this very often trying to use Panda3D.

I have learned some python .If somebody could just show me how to call one method I will be fine.
Do I have to end the method with “return”?
Thanks.

I took up panda3d as a way to find applications for the little python I know.

For all newbies like myself, courage.This is how you call the methods.
w = World()
w.setupLights()
w.startCarousel()
w.oscilatePanda()
w.run()
You can learn elementary python in two weeks.You can start doing stuff with it and grow with time.Cheers.