[Python-ideas] Extend unicodedata with a name search

Chris Angelico rosuav at gmail.com
Sat Oct 4 07:50:33 CEST 2014


On Sat, Oct 4, 2014 at 1:17 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
>   - startswith, endswith, contains: probably sufficient, but I suppose
>     one would like at least conjunction and disjunction operations:
>     unicodematch.contains('GREEK', 'SMALL', 'ALPHA', op='and')
>     unicodematch.startswith('PIECE OF', 'PILE OF', op='or')
>     (OK, that's pretty horrible, but it gives an idea.)

There's an easier way, though it would take a bit of setup work. Start
by building up an actual list in RAM of [unicodedata.name(chr(i)) for
i in range(sys.maxunicode+1)] and then do regular string operations.
I'm fairly sure most Python programmers can figure out how to search a
list of strings according to whatever rules they like - maybe using
contains/startswith/endswith, or maybe regexps, or whatever.

ChrisA


More information about the Python-ideas mailing list