As part of another experience i encountered a problem in the list comprehension. In order to put simply, if I am trying the following code:
m = [ k**2 for k in range(7)]
print m
[0, 1, 4, 9, 16, 25, 36]
print k
6
- My question is how is it python is able to get the value of k, outside the list comprehension?
- Why is k not garbage collected?
- Is this not a memory leak?