On May 20, 12:55 am, Laurent Luce wrote:
> I had a simple loop stripping each string but I was looking for
> something concise and efficient. I like the following answer:
> x = [s.rstrip('\n') for s in x]
Your initial requirement stated that you needed this to happen in-
place. What you're doing
On Tue, 19 May 2009 10:25:35 +0200, Piet van Oostrum wrote:
>> Laurent Luce (LL) wrote:
>
>>LL> I have the following list:
>
>>LL> [ 'test\n', test2\n', 'test3\n' ]
>
>>LL> I want to remove the '\n' from each string in place, what is the
>>LL> most efficient way to do that ?
>
> I suppose yo
Thanks Casey. I like your solution.
Casey Webster wrote:
> On May 18, 3:30 pm, Laurent Luce wrote:
>> I have the following list:
>>
>> [ 'test\n', test2\n', 'test3\n' ]
>>
>> I want to remove the '\n' from each string in place, what is the most
>> efficient way to do that ?
>>
>> Regards,
>>
>>
I had a simple loop stripping each string but I was looking for
something concise and efficient. I like the following answer:
x = [s.rstrip('\n') for s in x]
David Stanek wrote:
> On Mon, May 18, 2009 at 3:30 PM, Laurent Luce wrote:
>> I have the following list:
>>
>> [ 'test\n', test2\n', 'test3
On May 18, 3:30 pm, Laurent Luce wrote:
> I have the following list:
>
> [ 'test\n', test2\n', 'test3\n' ]
>
> I want to remove the '\n' from each string in place, what is the most
> efficient way to do that ?
>
> Regards,
>
> Laurent
Do you _really_ need to do this in place? If not, the simple
> Laurent Luce (LL) wrote:
>LL> I have the following list:
>LL> [ 'test\n', test2\n', 'test3\n' ]
>LL> I want to remove the '\n' from each string in place, what is the
>LL> most efficient way to do that ?
I suppose you mean you have lists similar to the one given because with
a list of 3
On Mon, May 18, 2009 at 8:30 PM, Laurent Luce wrote:
>
> I have the following list:
>
> [ 'test\n', test2\n', 'test3\n' ]
>
> I want to remove the '\n' from each string in place, what is the most
> efficient way to do that ?
>
> Regards,
>
> Laurent
> --
> http://mail.python.org/mailman/listinfo/p
On Mon, May 18, 2009 at 3:30 PM, Laurent Luce wrote:
>
> I have the following list:
>
> [ 'test\n', test2\n', 'test3\n' ]
>
> I want to remove the '\n' from each string in place, what is the most
> efficient way to do that ?
>
What have you tried so far?
--
David
blog: http://www.traceback.org
I have the following list:
[ 'test\n', test2\n', 'test3\n' ]
I want to remove the '\n' from each string in place, what is the most efficient
way to do that ?
Regards,
Laurent
--
http://mail.python.org/mailman/listinfo/python-list