understanding issue[researching]

ok lets first state that im not very knowledgable when it comes to termonologly of python so ill try to be as clear as possible.

I have 2 files (lets call them main.py and fileb.py) that i am working with. I had no problems when trying to set something in main and send it to fileb so that i dont have to open fileb so set the number. now I am trying to get a number from fileb and pass it to main so i can use it with my terrain info then pass the calulated info back over to fileb so that it can set the information. I had no problem setting up the second half but when I try to do the same call the first part (fileb to main) it dosnt work! there must be a special way to do this from your main file but i dont know what it is! See the code below for passing info from main to fileb:

In Main.py:

        camHandler = CameraHandler(Vec2(0, 100), 
                                   Vec2(0, 100), 
#the problem is here due to xC, and yC are in fileb.py and i dont know how to get them here!

in fileb.py:

class CameraHandler(DirectObject.DirectObject): 
   def __init__(self, plX, plY, tran, tran2): 

#skip a bunch of lines yhou dont need to see yet
      self.panLimitsX = plX
      self.panLimitsY = plY
      self.tran = tran
      self.tran2 = tran2

Ok i solved how to get fileb to main by getting infor from base.camera as my camera class was not able to at the point it was at. So that part is done although i found a new issue!

When i was passing info to my camera origionally i used:

camHandler = CameraHandler(Vec2(0, 100), Vec2(0, 100))

Which worked for what it needed to do although it only set the info during the camea startup which was all that was needed but now i want to change things and have it send info every frame but i dont know how to code this. I am working on getting the coding completed to set it each frame and have setup this in my main file:

    def cameraUpdate(self,task):
        self.tester = self.terrain.getElevation(base.camera.getX(),base.camera.getY())*self.terrain.getRoot().getSz()
#        print(self.tester)
#        print(base.camera.getZ())

        return Task.cont

an this will run every frame but now i need to pass the info off so i tried adding the code from the last snippet to this that was a bad idea as this caused the camera to reset every frame! so now I will try this:

In fileb:

def setgetattrib(Self,tester)
#insert the needed code here

Although im not quite sure what the needed code is! So ill work on it but if anyone has any suggestions please let me know!

here is an update on what is trying to happen:

#convo removed due to misunderstanding, sorry
#need to set method in a task to send to seperate class was the point

So this means i have to find the method I need the reference shows alot and most are undocuemtned although i fugre this one is documented or simple once i find it then i need to call the method in a task…

    def cameraUpdate(self, task):
        self.tester = self.terrain.getElevation(base.camera.getX(),base.camera.getY())*GeoMipTerrain("ground").getRoot().getSz()
        return Task.cont        

Ok so i got a task setup not i got to call the right method unfortunately i dont know how this works so im gonna keeep reading but if anyone knows feel free to let me know.

And yes this was what ive been trying to do this entire time but couldnt explain! Thank you to rdb for pointing me here not to find my code!

Edit: removed convo and added to post below:

I am reading about methods and oop programming it appears ive not been quite handling oop right and i will need to make some changes before i can impliment this properly.

ok i finally understand what i was told… This took days for me learn i just couldnt get my head around but in the end it was so easy!

Main.py: This is used to run something every frame and pass on the info to my other file btw camhandler (class of fileb)-crampCheck(def in fileb)

    def cameraUpdate(self, task):
        self.tester = self.terrain.getElevation(base.camera.getX(),base.camera.getY())*GeoMipTerrain("ground").getRoot().getSz()
        return Task.cont        

FileB.py: first def retrieves the info from main.py (as i couldnt seem to run a task and retrieve info) second def runs the info every frame!!!

    def crampCheck2(self,frank):
        self.frank = frank

    def crampCheck(self,task):
        print("Frank", self.frank)
        return task.cont

oh and one line in my init: this just sets an inital starup val before it can check for an actual one.


now i can finish my camera so it stays on the terrain!
I would like to thank Craig for the origin of the idea rdb who helped me get the understanding of OOP and thomas who helped with basic principles and trying to clear up my misconceptions!