How to maintain lists and dictionaries between function calls in Python?
02:23 07 Jan 2009

I have a function. Inside that I'm maintainfing a dictionary of values. I want that dictionary to be maintained between different function calls

Suppose the dic is:

a = {'a': 1, 'b': 2, 'c': 3}

At first call, say, I changed a['a'] to 100.

Dict becomes a = {'a': 100, 'b': 2, 'c': 3}.

At another call, I changed a['b'] to 200.

I want that dic to be a = {'a': 100, 'b': 200, 'c': 3}

But in my code a['a'] doesn't remain 100. It changes to initial value 1.

How do I maintain lists and dictionaries between function calls in Python?

python variables function-call