EDIT: I made some typos in my code. That’s why the simple example didn’t work.
This is kind of a weird and more general python question…
So, suppose I have two includes, A, B and main
class test1(DirectObject): def __init__(self): self.a = 1 def test2(self): self.b = a * 2 return self.b
class getTest(DirectObject): def __init__(self,app): self.app = app test = self.app.test2 print(test)
from direct.showbase.ShowBase import ShowBase from A import * from B import * class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) self.foo = test1() def getHandle(self): return self.foo app = MyApp() test = getTest(app.getHandle) app.run()
I get AttributeError: MyApp instance has no attribute ‘test2’ …however, what I’m trying to do is be able to basically pass the object reference that I created in “main.py” to file “a.py” and pass that handle in to “b.py” to call any additional methods that may have been defined in “a.py”
I promise, I’m not that dumb, but this seemingly simple python question is sort of outside the realm of things I normally do. Anyone have some advice for how to accomplish what I’m trying to do?