uuencodequoted-printableif this argument is passed in as (or equivalentlytrue)the payload' data is mime-decoded when fetchedif required because this argument is so useful for complex messages with arbitrary partsit will normally be passed as true in all cases binary parts are normally mime-encodedbut even text parts might also be present in base or another mime form if their bytes fall outside email standards some types of unicode textfor examplerequire mime encoding the upshot is that get_payload normally returns str strings for str text partsbut returns bytes strings if its decode argument is true--even if the message part is known to be text by nature if this argument is not usedthe payload' type depends upon how it was setstr or bytes because python does not allow str and bytes to be mixed freelyclients that need to use the result in text processing or store it in files need to accommodate the difference let' run some code to illustratefrom email message import message message( ['from''lancelotm set_payload('line' ['from''lancelotm get_payload('linem get_payload(decode= 'linestrif payload is str bytesif mime decode (same as decode=truethe combination of these different return types and python ' strict str/bytes dichotomy can cause problems in code that processes the result unless they decode carefullym get_payload(decode=true'spamtypeerrorcan' concat bytes to str get_payload(decode=truedecode('spam'linespamcan' mix in xconvert if required to make sense of these examplesit may help to remember that there are two different concepts of "encodingfor email textemail-style mime encodings such as base uuencodeand quoted-printablewhich are applied to binary and otherwise unusual content to make them acceptable for transmission in email text unicode text encodings for strings in generalwhich apply to message text as well as its partsand may be required after mime encoding for text message parts the email package handles email-style mime encodings automatically when we pass decode= to fetch parsed payloadsor generate text for messages that have nonprintable partsbut scripts still need to take unicode encodings into consideration because of client-side scripting