Okay, I know this is very confusing to type out. Let me clarify that I feel like this should work. I'll provide a simple example and the error (generalized to the example) that I receive.
class A:
FLAG = otherclass('flag')
def __init__(self):
self.half_val = 0
self.second_half_val = 0
def convert_value(self):
return "{}.{}".format(self.half_val, self.second_half_val)
def bring_in_B(self):
temp_val = self.convert_value()
self.member = B(self, temp_val)
return self.member
def __publish(self):
(do publishing stuff)
class B:
def __init__(self, A, address):
self.A = A
A.cap = cv2.VideoCapture(address)
self.cap = A.cap
...
def update(self):
...
self.grabbed, self.frame = self.cap.read()
self.A.__publish(arg1=self.A.FLAG, arg2=self.frame)
Error I receive:
in update
self.A.__publish(arg1=self.A.FLAG, arg2=self.frame)
AttributeError: 'A' object has no attribute '_B__publish'
I've tried to balance being general enough here while also sharing enough context, but please let me know if more information is needed. This isn't an IP-controlled project, so I can post the true code if necessary (it's just very long and I thought a slightly simpler example might serve better). Obviously I've removed elements where the "..." appears--there are otherwise no syntax issues, just the error I mentioned. The specific functions mentioned (particularly in class A) are also just placeholders here to highlight general functionality, and the real functions are a bit different (but not necessarily more complex to the point of adding any additional considerations).
I cannot, for the life of me, figure out why this isn't working properly, especially since the A.cap declaration works fine to create a new member while inside of another class. I feel like I'm definitely missing something obvious, and my lack of any formal training in Python might be to blame (all learned as needed). Any help or insight is greatly appreciated, cheers!
EDIT: that was quick...and dumb. I fixed it. Can't have it be "__publish" if I want to call it from another class, it has to be "publish". Looking into why. If anyone sees this and wants to participate in sharing why, please be my guest. Otherwise I'll leave this as a testament to other newbs to watch out for this kind of stuff.