def is_punct(text): for char in text: if not unicodedata.category(char).startswith('P'): return False else: return True