En Mon, 14 Apr 2008 04:08:06 -0300, Penny Y. <[EMAIL PROTECTED]> escribió:

>> lines[:] = [line.rstrip('\n') for line in lines]
>
> why not just:
>
> lines = [line.rstrip('\n') for line in lines]
>
>
> what's the difference between lines[:] and lines here? Thanks.

My version (using [:]) replaces the *contents* of the original list, but  
the list itself remains the same object.
Yours (without the [:]) reasigns a new list to the old name; the  
*contents* are the same as the former version, but now the name "lines"  
refers to a different list.
Depending on the context, the difference may be important or not.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to