Reference to list element question
skip at mojam.com
Wed Feb 16 20:14:30 CET 2000
David> The following code attempts to create a reference to a list
David> element to reduce overhead for large files, however the result is
David> a copy operation.
Yup. Strings are immutable (can't be modified in place). You would have to
do something like:
lines[i] = lines[i][:-1]
to delete the trailing newlines in lines[i].
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
"Languages that change by catering to the tastes of non-users tend not to do
so well." - Doug Landauer
More information about the Python-list