"""
    mailthon.helpers
    ~~~~~~~~~~~~~~~~

    Implements various helper functions/utilities.

    :copyright: (c) 2015 by Eeo Jun
    :license: MIT, see LICENSE for details.
"""

import mimetypes
from email.utils import formataddr


def guess(filename, fallback='application/octet-stream'):
    """
    Using the mimetypes library, guess the mimetype and
    encoding for a given *filename*. If the mimetype
    cannot be guessed, *fallback* is assumed instead.

    :param filename: Filename- can be absolute path.
    :param fallback: A fallback mimetype.
    """
    guessed, encoding = mimetypes.guess_type(filename, strict=False)
    if guessed is None:
        return fallback, encoding
    return guessed, encoding


def format_addresses(addrs):
    chunks = []
    for item in addrs:
        if isinstance(item, tuple):
            chunks.append(formataddr(item))
            continue
        chunks.append(item)
    return ', '.join(chunks)

@@ -759,197 +759,287 @@
     
-chunks = %5B%5D%0A    for item in addrs:%0A        if isinstance(item, tuple):%0A            chunks.append(formataddr(item))%0A            continue%0A        chunks.append(item)%0A    return ', '.join(chunks
+%22%22%22%0A    Given an iterable of addresses or name-address%0A    tuples *addrs*, return a header value that joins%0A    all of them together with a space and a comma.%0A    %22%22%22%0A    return ', '.join(%0A        formataddr(item) if isinstance(item, tuple) else item%0A        for item in addrs%0A    
 )%0A

make format_addresses more Pythonic, add docs