[Tutor] redemo.py and r'python\.org'

Kent Johnson kent37 at tds.net
Fri Oct 14 12:04:14 CEST 2005


Dick Moores wrote:
> Kent Johnson wrote at 19:21 10/13/2005:
> 
>> > BTW in redemo.py, what do the checkboxes VERBOSE, LOCALE, and DOTALL
>> > mean? (I understand IGNORECASE and MULTILINE.)
>>
>> http://docs.python.org/lib/node115.html
> 
> 
> OK, but that didn't help with LOCALE. From 
> http://en.wikipedia.org/wiki/Locale
> LOCALE seems to be something I don't need to worry about for a while.

LOCALE
    Make \w, \W, \b, \B, \s and \S dependent on the current locale.

Locale is a setting that affects some operations that differ in different cultures, for example whether a . or , is used as a decimal separator and what the money symbol is. You can access locale settings with the locale module.

The list of word and space characters can differ by locale. This affects the meaning of the \ escapes noted above. Even setting the locale to 'en' (from the default 'C' locale) changes the default letters:

 >>> import string, locale
 >>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
 >>> locale.setlocale(locale.LC_ALL, 'en')
'English_United States.1252'
 >>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\
xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf
6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
 >>>

Kent



More information about the Tutor mailing list