Python Forum

Full Version: string.punctuation for languages like French or German
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
string.punctuation gives me '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~',
but that's not sufficient for other languages like French or German. What I can I do with other languages?
You could make a unicode_punctuation.

https://stackoverflow.com/questions/6098...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).