[Tutor] Python for Windows: module re, re.LOCALE differen
t fo r Idle and p ython shell?
Steckel, Ralf
Ralf.Steckel at AtosOrigin.com
Thu Jul 29 16:29:58 CEST 2004
Hi Steve,
the locale module led me on the right track:
In Idle 'loc=locale.getlocale(locale.LC_CTYPE)' prints '['de_DE', '1252']'.
In python shell 'loc=locale.getlocale(locale.LC_CTYPE)' prints
'(None,None)'.
Setting the default locale by 'locale.setlocale(locale.LC_ALL, '')' sets the
locale to ['de_DE', '1252'].
Setting 'de_DE' or 'en_EN' or 'POSIX' always reports 'unsupported locale
setting'. The only other possible locale setting which i got working is 'C'.
By the way if i call in Idle 'locale.getlocale(locale.LC_ALL)' before
setting the LC_ALL i get the following runtime error:
Traceback (most recent call last):
File "D:\Src\Python\wordcount\umlaute.py", line 3, in -toplevel-
loc = locale.getlocale(locale.LC_ALL)
File "D:\Python23\Lib\locale.py", line 364, in getlocale
raise TypeError, 'category LC_ALL is not supported'
TypeError: category LC_ALL is not supported
But nevertheless, by setting the locale to the default locale on a German
Windows OS i get what I want.
Thank you,
Steve!
- Ralf
> -----Original Message-----
> From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
> Behalf Of Steve
> Sent: Thursday, July 29, 2004 3:20 PM
> To: tutor at python.org
> Subject: Re: RE: [Tutor] Python for Windows: module re, re.LOCALE
> different fo r Idle and p ython shell?
>
>
> Hi Ralf,
>
> On Thu, 29 Jul 2004 13:22:11 +0200, Steckel, Ralf
> <ralf.steckel at atosorigin.com> wrote:
> > thanx for your suggestion (what actually made me to improve
> my script by
> > opening the file via codecs), but this doesn't fix the problem.
>
> You are welcome.
>
> <...snip...>
> > By using the codecs.open with encoding = 'iso-8859-1' my
> basic problem (re
> > doesn't recognize German Umlaute as valid characters in re
> in Python shell)
> > still exists.
>
> Oh ok. Well unfortunately, I am reading this using the gmail web
> interface and I ran your script on my linux box, and so I can't
> reproduce the behaviour that you are experiencing.
> In any case, this seems to be (like you, yourself mentioned) a
> problem with the environment rather than with python, so here's
> another shot in the dark. ....have you considered setting a default
> locale for the script by using the 'locale' module ??
>
> ie:
> import locale
> locale.setlocale(locale.LC_ALL, 'de_DE')
> <the rest of your program>
>
>
> HTH
> Steve
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list