Program not Stripping Headers from Email though Working fine

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Thu Mar 4 15:27:44 EST 2004


On Thu, 4 Mar 2004 00:40:16 -0800 (PST), dont bother wrote:
> for hdr in msg.keys():
> 	if hdr.startswith('From'):
> 		del msg[hdr]

Don't modify the list you're iterating over.  Make a copy, and iterate
over that.

    msg_keys = msg.keys()
    for hdr in msg_keys:
        if hdr.startswith( 'From' ):
            del msg[hdr]

-- 
 \         "I may disagree with what you say, but I will defend to the |
  `\    death your right to mis-attribute this quote to Voltaire."  -- |
_o__)                      Avram Grumer, rec.arts.sf.written, May 2000 |
Ben Finney <http://bignose.squidly.org/>



More information about the Python-list mailing list