(addrstring)
return "<%s>" % addr
Quote a subset of the email addresses defined by RFC 821.

    Should be able to handle anything email.utils.parseaddr can handle.
Quote a subset of the email addresses defined by RFC 821.
Quote a subset of the email addresses defined by RFC 821 .
def quoteaddr(addrstring):
    """Quote a subset of the email addresses defined by RFC 821.

    Should be able to handle anything email.utils.parseaddr can handle.
    """
    displayname, addr = email.utils.parseaddr(addrstring)
    if (displayname, addr) == ('', ''):
        # parseaddr couldn't parse it, use it as is and hope for the best.
        if addrstring.strip().startswith('<'):
            return addrstring
        return "<%s>" % addrstring
    return "<%s>" % addr
def quoteaddr ( addrstring ) : displayname , addr = email . utils . parseaddr ( addrstring ) if ( displayname , addr ) == ( '' , '' ) : # parseaddr couldn't parse it, use it as is and hope for the best. if addrstring . strip ( ) . startswith ( '<' ) : return addrstring return "<%s>" % addrstring return "<%s>" % addr