In Python 3, passing a reference to an object in name space to del
does not work when wrapped in a list.
a = 'foo'
for x in [a]:
del(x)
print(a)
del(a)
print(a)
The first call to del
silently does nothing, only the second one deletes a
. Why does this happen, and how would I pass references in a list to del
to delete the reference (in this case a
)?