def header_length ( bytearray ) : groups_of_3 , leftover = divmod ( len ( bytearray ) , 3 ) # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in. n = groups_of_3 * 4 if leftover : n += 4 return n
how to determine length of python email message in bytes
Return the length of s when it is encoded with base64 .
def header_length(bytearray):
    """Return the length of s when it is encoded with base64."""
    groups_of_3, leftover = divmod(len(bytearray), 3)
    # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
    n = groups_of_3 * 4
    if leftover:
        n += 4
    return n