def gen_bidirectional(cats): for i in range(0, 0x110000): if unicodedata.bidirectional(unichr(i)) in cats: yield(i)