def encode_rfc2822_address_header(header_text):
 def encode_addr(addr):
  (name, email) = addr
  if (not try_coerce_ascii(name)):
   name = str(Header(name, 'utf-8'))
  return formataddr((name, email))
 addresses = getaddresses([ustr(header_text).encode('utf-8')])
 return COMMASPACE.join(map(encode_addr, addresses))

def encode_rfc2822_address_header ( header_text ) : def encode_addr ( addr ) : ( name , email ) = addr if ( not try_coerce_ascii ( name ) ) : name = str ( Header ( name , 'utf-8' ) ) return formataddr ( ( name , email ) ) addresses = getaddresses ( [ ustr ( header_text ) . encode ( 'utf-8' ) ] ) return COMMASPACE . join ( map ( encode_addr , addresses ) )
if header_text contains non-ascii characters .