Dan Bishop wrote: >>> lines[:] = [line.rstrip('\n') for line in lines] >> What is the point of the [:] after lines ? How different is it with or >> without it ? > > It causes the result to be stored in the existing list. >
If we do: lines = [line.rstrip('\n') for line in lines] lines is now a new list, the old list as no reference to it, and will be discarded by the gc, right ? So we're not really saving any space here ? 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 ? Thanks. Yves. http://www.SollerS.ca -- http://mail.python.org/mailman/listinfo/python-list