my class structure is something like this.
class A():
def __init__(self):
self.matched_condition_set = set()
def add_to_matched_condition(self,condition):
self.matched_condition_set.add(condition)
class B():
def __init__(self, list_of_A):
self.list_of_a = list_of_A
def do_stuff(self):
for a in self.list_of_a:
if helper.check_for_a(a):
print(a.matched_condition_set)
in a file called helper.py i have the following function.
def check_for_a(a):
print(type(a))
a.add_to_matched_condition("hello")
return True
Now if i call class B object, I get that:
A instance has no attribute 'add_to_matched_condition'
.
also when I try to get the type of a >> print(type(a)) inside the helper method. i get type<'instance'>.
where is the object getting lost ?
call class B object?a = A(); b = B([a]); b.do_stuff()results in<type 'instance'>andset(['hello']).