My code:
locs = [ [1], [2] ]
for loc in locs:
loc = []
print locs
# prints => [ [1], [2] ]
Why is loc not reference of elements of locs?
In Python, everything is passed as reference unless explicitly copied (is this not true?)
How does Python decide referencing and copying?
How to do?
def compute(ob):
if isinstance(ob,list): return process_list(ob)
if isinstance(ob,dict): return process_dict(ob)
for loc in locs:
loc = compute(loc) # What to change here to make loc a reference of actual locs iteration?
- locs must contain the final processed response
- I don't want to use
enumerate, is it possible without it?