class Test:
TheFlag = True
StartNodeQuery = {1, 2, 3, 4, 5}
def parsa(self):
while self.TheFlag:
SNQ = self.StartNodeQuery
self.iterator(SNQ)
def iterator(self, CurrentNodeQuery):
#it prints {1, 2, 3, 4, 5}
print(CurrentNodeQuery)
if len(CurrentNodeQuery) < 100:
b = len(CurrentNodeQuery) * 2
c = len(CurrentNodeQuery) * 3
self.StartNodeQuery.update({b, c})
# it prints {1, 2, 3, 4, 5, 10, 15}
print(CurrentNodeQuery)
else:
self.TheFlag = False
assert 0
obj = Test()
obj.parsa()
as you can see I deliberately ended the program with assert 0. The Main issue is: Before the function is finished the parameters that is passed to it gets changed!
as you can see StartNodeQuery = {1, 2, 3, 4, 5} and SNQ = self.StartNodeQuery
so why when I change the size of the self.StartNodeQuery inside the function before it's finished , CurrentNodeQuery which is a different variable with the same values as self.StartNodeQuery (or SNQ) gets changed as well, even though we didn't pass the new self.StartNodeQuery to CurrentNodeQuery yet?
I hope you understand my problem, if you have the solution, please help a guy out