Python Forum
string.punctuation for languages like French or German - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: string.punctuation for languages like French or German (/thread-27420.html)



string.punctuation for languages like French or German - Leo978 - Jun-06-2020

string.punctuation gives me '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~',
but that's not sufficient for other languages like French or German. What I can I do with other languages?


RE: string.punctuation for languages like French or German - DeaD_EyE - Jun-06-2020

You could make a unicode_punctuation.

https://stackoverflow.com/questions/60983836/complete-set-of-punctuation-marks-for-python-not-just-ascii
import sys
from unicodedata import category


punctuation_chars =  [
    chr(i) for i in range(sys.maxunicode)
    if category(chr(i)).startswith("P")
    ]
If you have to work with foreign languages, look for gettext and babel. The programmer does i18n (internationalization) and the translators are doing the l10n (localization).