On Wed, Oct 17, 2012 at 9:32 AM, <wxjmfa...@gmail.com> wrote: >>>> import unicodedata >>>> def HasDiacritics(w): > ... w_decomposed = unicodedata.normalize('NFKD', w) > ... return 'no' if len(w) == len(w_decomposed) else 'yes' > ... >>>> HasDiacritics('éléphant') > 'yes' >>>> HasDiacritics('elephant') > 'no' >>>> HasDiacritics('\N{LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON}') > 'yes' >>>> HasDiacritics('U') > 'no'
Is there something wrong with True and False that you had to replace them with strings? "return len(w) != len(w_decomposed)" is all you need. -- http://mail.python.org/mailman/listinfo/python-list