How to get the date format from the users locale?

Fabio Zadrozny fabiofz at gmail.com
Fri Jun 25 07:39:43 EDT 2010


I'm trying to get the locale-aware date format but it doesn't seem to
be available through nl_langinfo in python 2.5.4 (windows vista).

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] onType "help", "copyright", "credits" or "license" for more
information.
>>> import locale;locale.nl_langinfo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'nl_langinfo'


Is that what I should be using? Is there any other way for getting that info?

Thanks,

Fabio


>>> print '\n'.join(sorted(dir(locale)))
CHAR_MAX
Error
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
__all__
__builtins__
__doc__
__file__
__name__
_build_localename
_group
_parse_localename
_percent_re
_print_locale
_setlocale
_test
atof
atoi
currency
encodings
format
format_string
getdefaultlocale
getlocale
getpreferredencoding
locale_alias
locale_encoding_alias
localeconv
normalize
operator
re
resetlocale
setlocale
str
strcoll
strxfrm
sys
windows_locale
>>>



More information about the Python-list mailing list