def formataddr(pair):
 (name, address) = pair
 if name:
  quotes = ''
  if specialsre.search(name):
   quotes = '"'
  name = escapesre.sub('\\\\\\g<0>', name)
  return ('%s%s%s <%s>' % (quotes, name, quotes, address))
 return address

def formataddr ( pair ) : ( name , address ) = pair if name : quotes = '' if specialsre . search ( name ) : quotes = '"' name = escapesre . sub ( '\\\\\\g<0>' , name ) return ( '%s%s%s <%s>' % ( quotes , name , quotes , address ) ) return address
the inverse of parseaddr() .