> Thanks to all respondents, Steve Holden
> is right, I expected more than I should
> have.

Others have explained why all your examples work as they should.
>From your exmaples, it seems like you would like strip to
remove the leading and trailing characters from EVERY LINE in
your string. This can be done by the simple construct

>>> my_string = '  foo    \n bar   '
>>> '\n'.join(line.strip() for line in my_string.split('\n'))
'foo\nbar'

If you need this construct at several places, define a function

def line_strip(string,sep='\n') :
    return sep.join(line.strip() for line in string.split(sep))

cheers,

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

Reply via email to