in the code here How do I force static methods to use local not global variables in Python?
i have a variable that is being passed between methods besides the one in the question. the variable is current_line
def line_tocsv(csv_dict={}, line={}, current_line=0):
csv_line, current_line = LineHandler.create_csv(current_line, kline)
if current_line in csv_dict:
csv_dict[current_line].update(csv_line)
else:
csv_dict[current_line] = csv_line
return csv_dict
when this code is run, it produced an output simmilar to this
>>> a={0:{"aa":1,"bb":"wasd"},1:{"aa":1,"bb":"wasd"}}
>>> a
{0: {'aa': 1, 'bb': 'wasd'}, 1: {'aa': 1, 'bb': 'wasd'}}
>>> a[1].update({"cc":"foo"})
>>> a
{0: {'aa': 1, 'cc': 'foo' 'bb': 'wasd'}, 1: {'aa': 1, 'cc': 'foo', 'bb': 'wasd'}}
how do i make it so that the csv_line dict is only entered into ONE sub dict?! changing the variable names does not work and i suspect it is because only the references are passed between functions, but i dont know enough python to know where those references actually go and what their order of ops etc is