Re: Chopping off spaces at both ends

2005-08-08 Thread Tim Roberts
Madhusudan Singh <[EMAIL PROTECTED]> wrote: > >I am a newbie to python and am using it to interface some of my lab >equipment. > >How does one get rid of spaces at both ends of a string ? A little > like the >trim() intrinsic in fortran 95. > >One of my instruments is retur

Re: Chopping off spaces at both ends

2005-08-07 Thread Bengt Richter
On 7 Aug 2005 10:14:33 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >Use the strip() method. > >Example: > "\t abc\n".strip() >"abc" > >Variants are lstrip() and rstrip(). > and also occasionally useful: >>> 'abc123cab'.strip('bca') '123' I.e., a strip argument as an unordered se

Re: Chopping off spaces at both ends

2005-08-07 Thread Kay Schluehr
Use the strip() method. Example: >>> "\t abc\n".strip() "abc" Variants are lstrip() and rstrip(). Regards, Kay -- http://mail.python.org/mailman/listinfo/python-list

Chopping off spaces at both ends

2005-08-07 Thread Madhusudan Singh
Hi I am a newbie to python and am using it to interface some of my lab equipment. How does one get rid of spaces at both ends of a string ? A little like the trim() intrinsic in fortran 95. One of my instruments is returning a string that has one or more blanks in it, a