Re: simple string search and replace

2006-03-25 Thread Steve Holden
Kun wrote: > hey guys, here's my code, > > senders = [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend > <[EMAIL PROTECTED]>\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS > (FROM)] {37}', 'From: Kun <[EMAIL PROTECTED]>\r\n\r\n'), ')'] > print senders > parsed_senders = [] > sender = "" > for i

Re: simple string search and replace

2006-03-25 Thread bearophileHUGS
Generally, to remove a substring (like ">") from a string you can use the replace method (that returns a new string): >>> s = "...anon.wharton.com>..." >>> s.replace(">", "") '...anon.wharton.com...' You can use it with something like: print [s.replace(">", "") for s in parsed_senders] or you ca

simple string search and replace

2006-03-25 Thread Kun
hey guys, here's my code, senders = [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend <[EMAIL PROTECTED]>\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}', 'From: Kun <[EMAIL PROTECTED]>\r\n\r\n'), ')'] print senders parsed_senders = [] sender = "" for item in senders: if isinst