Consider:
args = ['-sdfkj']
print args
for arg in args:
print arg.replace("-", '')
arg = arg.replace("-", '')
print args
This yields:
['-sdfkj']
sdfkj
['-sdfkj']
Where I expected it to be ['sdfkj']
.
Is arg
in the loop a copy?
It behaves as if it is a copy (or perhaps an immutable thingie, but then I expect an error would be thrown...)
Note: I can get the right behavior with a list comprehension. I am curious as to the cause of the above behavior.