¡@

Home 

python Programming Glossary: locale

Writing unicode strings via sys.stdout in Python

http://stackoverflow.com/questions/1473577/writing-unicode-strings-via-sys-stdout-in-python

to try out the following code python c 'import sys codecs locale print str sys.stdout.encoding sys.stdout codecs.getwriter locale.getpreferredencoding.. print str sys.stdout.encoding sys.stdout codecs.getwriter locale.getpreferredencoding sys.stdout However this too does not work.. too does not work at least on Mac . Too see why import locale locale.getpreferredencoding 'mac roman' sys.stdout.encoding..

Python: is using “..%(var)s..” % locals() a good practice?

http://stackoverflow.com/questions/1550479/python-is-using-vars-locals-a-good-practice

for users with some to you obscure combinaton of language locale and preferences If you have superb integration regression testing..

Parsing Dates and Times from Strings using python [duplicate]

http://stackoverflow.com/questions/1713594/parsing-dates-and-times-from-strings-using-python

how to print number with commas as thousands separators in Python 2.x

http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x

for the simplest practical way. It does not need to be locale specific to decide between periods and commas. I would prefer.. share improve this question I got this to work import locale locale.setlocale locale.LC_ALL 'en_US' 'en_US' locale.format.. improve this question I got this to work import locale locale.setlocale locale.LC_ALL 'en_US' 'en_US' locale.format d 1255000..

Python - Is a dictionary slow to find frequency of each character?

http://stackoverflow.com/questions/2522152/python-is-a-dictionary-slow-to-find-frequency-of-each-character

wifstream f argv argc 1 assume the file has utf 8 encoding locale utf8_locale locale new boost program_options detail utf8_codecvt_facet.. argv argc 1 assume the file has utf 8 encoding locale utf8_locale locale new boost program_options detail utf8_codecvt_facet f.imbue.. 1 assume the file has utf 8 encoding locale utf8_locale locale new boost program_options detail utf8_codecvt_facet f.imbue..

How do I sort a list of strings in Python?

http://stackoverflow.com/questions/36139/how-do-i-sort-a-list-of-strings-in-python

the examples above are a bit naive because they don't take locale into account and perform a case sensitive sorting. You can take.. once per element . So to sort according to the current locale taking language specific rules into account cmp_to_key is a.. function from functools sorted mylist key cmp_to_key locale.strcoll And finally if you need you can specify a custom locale..

Natural/Relative days in Python

http://stackoverflow.com/questions/410221/natural-relative-days-in-python

searchers The babel module which deals with all sorts of locale stuff has a function for doing more or less what you want. Currently.. delta timedelta days 6 format_timedelta delta locale 'en_US' u'1 week' This is taken straight from the babel documentation.. functions for formatting dates and times according to locale Which might be useful when the time delta is large. share improve..

UnicodeDecodeError when redirecting to file

http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file

a solution like this for Python 2.x import codecs import locale import sys # Wrap sys.stdout into a StreamWriter to allow writing.. to allow writing unicode. sys.stdout codecs.getwriter locale.getpreferredencoding sys.stdout uni u u001A u0BC3 u1451 U0001D10C..

What is the correct way to set Python's locale?

http://stackoverflow.com/questions/955986/what-is-the-correct-way-to-set-pythons-locale

is the correct way to set Python's locale I'm attempting to sort a list of strings in a locale aware.. locale I'm attempting to sort a list of strings in a locale aware manner. I've used the Babel library for other i18n related.. related tasks but it doesn't support sorting. Python's locale module provides a strcoll function but requires the locale of..