def typed_subpart_iterator(msg, maintype='text', subtype=None):
 for subpart in msg.walk():
  if (subpart.get_content_maintype() == maintype):
   if ((subtype is None) or (subpart.get_content_subtype() == subtype)):
    (yield subpart)

def typed_subpart_iterator ( msg , maintype = 'text' , subtype = None ) : for subpart in msg . walk ( ) : if ( subpart . get_content_maintype ( ) == maintype ) : if ( ( subtype is None ) or ( subpart . get_content_subtype ( ) == subtype ) ) : ( yield subpart )
iterate over the subparts with a given mime type .