Search code examples
pythonlocale

Is str(Bool) locale dependent


When in a python script I write

>>> v = True
>>> str(v).upper()
'TRUE'

can I assume that 'TRUE' will always be the result, or can I have a translation of True in user terminal language (e.g 'WAHR' if user terminal is in German)?


Solution

  • It will always be TRUE, but if you want to hardcode it yourself:

    print( 'TRUE' if v else 'FALSE' )