When I assign a Global list to a local list and edit this local list both the list get edited. Is it because list in python are pointer, similar to array in C?
>>> source = [(0, 5), (1, 5), (2, 5), (3, 5), (4, 5)]
>>> def s():
... source_queue = source
... while len(source_queue)>0:
... f(source_queue)
...
>>> def f(source_queue):
... (x,y) = source_queue.pop(0)
... print (x,y) in source
... print source,source_queue
...
>>> s()
Output:
False
[(1, 5), (2, 5), (3, 5), (4, 5)] [(1, 5), (2, 5), (3, 5), (4, 5)]
False
[(2, 5), (3, 5), (4, 5)] [(2, 5), (3, 5), (4, 5)]
False
[(3, 5), (4, 5)] [(3, 5), (4, 5)]
False
[(4, 5)] [(4, 5)]
False
[] []