def split_addr(addr, encoding):
 if ('@' in addr):
  (localpart, domain) = addr.split('@', 1)
  try:
   localpart.encode('ascii')
  except UnicodeEncodeError:
   localpart = Header(localpart, encoding).encode()
  domain = domain.encode('idna').decode('ascii')
 else:
  localpart = Header(addr, encoding).encode()
  domain = ''
 return (localpart, domain)

def split_addr ( addr , encoding ) : if ( '@' in addr ) : ( localpart , domain ) = addr . split ( '@' , 1 ) try : localpart . encode ( 'ascii' ) except UnicodeEncodeError : localpart = Header ( localpart , encoding ) . encode ( ) domain = domain . encode ( 'idna' ) . decode ( 'ascii' ) else : localpart = Header ( addr , encoding ) . encode ( ) domain = '' return ( localpart , domain )
split the address into local part and domain .