Alphabetics respect to a given locale

C

candide

How to retrieve the list of all characters defined as alphabetic for the
current locale ?
 
E

Emile van Sebille

On 4/1/2011 1:55 PM candide said...
How to retrieve the list of all characters defined as alphabetic for the
current locale ?

I think this is supposed to work, but not for whatever reason for me
when I try to test after changing my locale (but I think that's a centos
thing)...

import locale
locale.setlocale(locale.LC_ALL,'')
import string
print string.lowercase

I don't see where else this might be for python.

However, you can test if something is alpha:

.... and check its unicode category
'Cc' #


HTH,

Emile
 
C

candide

Le 01/04/2011 22:55, candide a écrit :
How to retrieve the list of all characters defined as alphabetic for the
current locale ?


Thanks for the responses. Alas, neither solution works.

Under Ubuntu :

# ----------------------
import string
import locale

print locale.getdefaultlocale()
print locale.getpreferredencoding()

locale.setlocale(locale.LC_ALL, "")

print string.letters

letter_class = u"[" + u"".join(unichr(c) for c in range(0x10000) if
unichr(c).isalpha()) + u"]"

#print letter_class
# ----------------------

prints the following :


('fr_FR', 'UTF8')
UTF-8
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz


I commented out the letter_class printing for outputing a flood of
characters not belonging to the usual french character set.


More or less the same problem under Windows, for instance,
string.letters gives the "latin capital letter eth" as an analphabetic
character (this is not the case, we never use this letter in true french
words).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top