def pretty_try_use_unicode():
 try:
  symbols = []
  symbols.extend(greek_unicode.values())
  symbols += atoms_table.values()
  for s in symbols:
   if (s is None):
    return
   encoding = getattr(sys.stdout, 'encoding', None)
   if (encoding is None):
    return
   s.encode(encoding)
 except UnicodeEncodeError:
  pass
 else:
  pretty_use_unicode(True)

def pretty_try_use_unicode ( ) : try : symbols = [ ] symbols . extend ( greek_unicode . values ( ) ) symbols += atoms_table . values ( ) for s in symbols : if ( s is None ) : return encoding = getattr ( sys . stdout , 'encoding' , None ) if ( encoding is None ) : return s . encode ( encoding ) except UnicodeEncodeError : pass else : pretty_use_unicode ( True )
see if unicode output is available and leverage it if possible .