Stripping new lines from strings?

Simon Brunning SBrunning at trisystems.co.uk
Tue Aug 15 11:00:34 EDT 2000


> From:	Richard Chamberlain [SMTP:richard_chamberlain at ntlworld.com]
> Presuming you don't want any space at the end you can use string.strip
> so...
> 
> import string
> p="I line with a newline.\n"
> q=string.rstrip(p)
> 
By default, string.split splits at whitespace, but it has an optional second
argument, which allows you to split by any string. Wouldn't it be nice if
string.strip and its siblings had a similar 2nd argument...

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list