Python and i18n

  • Thread starter =?ISO-8859-1?Q?Jo=E3o?= Alfredo
  • Start date
?

=?ISO-8859-1?Q?Jo=E3o?= Alfredo

Hi people.

My LANG environment variable is set to pt_BR.UTF-8 and when raw a date
command:

$ date
Sáb Out 18 11:19:42 BRT 2003
I get the current date in the apropriate locale.

Now when i raw the following command in the python interpreter:

$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.i get the date in US locale format.

So, does python support the pt_BR locale?? Am I doing something wrong??

Thanks in advance!
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

João Alfredo wrote:

So, does python support the pt_BR locale?? Am I doing something wrong??

Yes, and yes. You have to invoke locale.setlocale(locale.LC_ALL,"")
first.

Regards,
Martin
 
P

Peter Otten

João Alfredo said:
Hi people.

My LANG environment variable is set to pt_BR.UTF-8 and when raw a date
command:

$ date
Sáb Out 18 11:19:42 BRT 2003
I get the current date in the apropriate locale.

Now when i raw the following command in the python interpreter:

$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.i get the date in US locale format.

So, does python support the pt_BR locale?? Am I doing something wrong??

You have to set the locale explicitly:
'pt_PT.ISO8859-1'

Even then asctime() will not work as you wish:
'Sat Oct 18 20:44:29 2003'


But strftime() has it right:

Peter
 

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,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top