En Tue, 15 Apr 2008 20:26:16 -0300, Yves Dorfsman <[EMAIL PROTECTED]>
escribió:
> 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 e
On Apr 16, 9:26 am, Yves Dorfsman <[EMAIL PROTECTED]> 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
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
On Apr 14, 10:55 pm, Yves Dorfsman <[EMAIL PROTECTED]> wrote:
> Gabriel Genellina wrote:
> > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam
> >> l=['5\n', '2\n', '7\n', '3\n', '6\n']
>
> >> how to remove \n from the given list
>
> > l is is very poor name... I'll use lines instead:
>
> > lines[:
Gabriel Genellina wrote:
> En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam
>> l=['5\n', '2\n', '7\n', '3\n', '6\n']
>>
>> how to remove \n from the given list
>
> l is is very poor name... I'll use lines instead:
>
> lines[:] = [line.rstrip('\n') for line in lines]
When I saw the original me
that's right. got it thanks.
-邮件原件-
发件人: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 代表 Eric Brunel
发送时间: 2008年4月14日 16:17
收件人: python-list@python.org
主题: Re: 答复: how to remove \n in the list
(please avoid top-posting... corrected)
On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. &l
(please avoid top-posting... corrected)
On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. <[EMAIL PROTECTED]> wrote:
> -邮件原件-
> 发件人: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] 代表 Gabriel
> Genellina
> 发送时间: 2008年4月14日 12:59
> 收件人: python-list@python.org
> 主题: Re: h
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 t
2008年4月14日 12:59
收件人: python-list@python.org
主题: Re: how to remove \n in the list
En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam
<[EMAIL PROTECTED]> escribió:
> hi,
> l=['5\n', '2\n', '7\n', '3\n', '6\n']
>
> how to remove \n
On Apr 14, 2:58 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam
> <[EMAIL PROTECTED]> escribió:
>
> > hi,
> > l=['5\n', '2\n', '7\n', '3\n', '6\n']
>
> > how to remove \n from the given list
>
> l is is very poor name... I'll use lines instead:
En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam
<[EMAIL PROTECTED]> escribió:
> hi,
> l=['5\n', '2\n', '7\n', '3\n', '6\n']
>
> how to remove \n from the given list
l is is very poor name... I'll use lines instead:
lines[:] = [line.rstrip('\n') for line in lines]
--
Gabriel Genellina
--
hi,
l=['5\n', '2\n', '7\n', '3\n', '6\n']
how to remove \n from the given list
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo