how to remove \n in the list

alex23 wuwei23 at
Wed Apr 16 02:12:03 CEST 2008

On Apr 16, 9:26 am, Yves Dorfsman <y... at> wrote:
> If we do:
> lines[:] = [line.rstrip('\n') for line in lines]
> We reuse an existing list, therefore we are saving the time it takes to
> create a new list ? So this is a performance issue ?

I think it's more of a reference issue. You may have other labels
already pointing to 'lines', if you want them to refer to the same,
rstrip'd list, you'd do an in-place update like this.

- alex23

More information about the Python-list mailing list