If you need to do this often, it's easy enough to create a reusable map for yourself:
import sys import unicodedata from collections import defaultdict unicode_category = defaultdict(list) for c in map(chr, range(sys.maxunicode + 1)): unicode_category[unicodedata.category(c)].append(c)
And from there, use this card to translate it into a series of characters for this category:
alphabetic = unicode_category['Ll']
If it is too expensive for startup time, think about how to delete this structure in a file; loading this mapping from a JSON file or other syntax quick access format should not be too painful.
Once you have a match, the category search is performed in constant time, of course.
source share