[Tutor] question about locale.setlocale

Rafael Durán Castañeda rafadurancastaneda at gmail.com
Thu Feb 3 14:34:28 CET 2011


Hi all,

I'm new in Python, so I'm reading 3.1 tutorial and now I've got a question
about locale.setlocale function. I've tryed in python idle this:

import locale

locale.setlocale(locale.LC_ALL, 'English_United States.1252')

and i got:

Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    locale.setlocale(locale.LC_ALL,'English_United States.1252')
  File "/usr/lib/python3.1/locale.py", line 527, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

After that I checked locale.py trying to know which locale settings are
supported I found:

def setlocale(category, value=None):
        """ setlocale(integer,string=None) -> string.
            Activates/queries locale processing.
        """
        if value not in (None, '', 'C'):
            raise Error('_locale emulation only supports "C" locale')
        return 'C'

So here I can use only default (es_ES.utf8) and C locales, but how can I use
any other locale?

Bye
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110203/78379bc2/attachment.html>


More information about the Tutor mailing list