How to preserve a list or a dict in python recursive function?
<p>I have to use a recursive function in python, code below is a simplified model.
I want to preserve result list and dict dictionary not generate a new list or dictionary while in the recursive, and return it after recursive, how to solve it?</p>

<pre><code>def test(length):
    result = []
    dict = {}
    if length == 10:
        return result, dict
    else:
        result.append(length)
        dict[length] = length + 1
        test(length + 1)

x, y = test(0)
print x, y
</code></pre>
