def body_line_iterator(msg, decode=False):
 for subpart in msg.walk():
  payload = subpart.get_payload(decode=decode)
  if isinstance(payload, basestring):
   for line in StringIO(payload):
    (yield line)

def body_line_iterator ( msg , decode = False ) : for subpart in msg . walk ( ) : payload = subpart . get_payload ( decode = decode ) if isinstance ( payload , basestring ) : for line in StringIO ( payload ) : ( yield line )
iterate over the parts .