RE: print() and unicode strings (python 3.1)

2009-08-26 Thread Anonymous
Have you considered including an encoding line at the top of your file, as described in PEP 0263: http://www.python.org/dev/peps/pep-0263/ I just ran into a similar error, but it went away when I included # coding: utf-8 as the first line in my file. -- http://mail.python.org/mailman/listinfo

Re: print() and unicode strings (python 3.1)

2009-08-26 Thread 7stud
On Aug 25, 6:34 am, Nobody wrote: > The underlying OS primitive can only handle bytes. If you read or write a > (unicode) string, Python needs to know which encoding is used. For Python > file objects created by the user (via open() etc), you can specify the > encoding; for those created by the ru

Re: print() and unicode strings (python 3.1)

2009-08-26 Thread Piet van Oostrum
> 7stud (7) wrote: >7> Thanks for the response. My OS is mac osx 10.4.11. I'm not really >7> sure how to check my locale settings. Here is some stuff I tried: >7> $ echo $LANG >7> $ echo $LC_ALL >7> $ echo $LC_CTYPE >7> $ locale >7> LANG= >7> LC_COLLATE="C" >7> LC_CTYPE="C" >7> LC_MESS

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread Nobody
On Tue, 25 Aug 2009 03:41:54 -0700, 7stud wrote: > Why does echoing $LC_ALL or $LC_CTYPE just give me a blank string? Because the variables aren't set. The default locale for a particular category (e.g. LC_CTYPE) is taken from $LC_ALL if that is set, otherwise $LC_CTYPE, otherwise $LANG, otherwi

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread 7stud
On Aug 24, 10:09 pm, Ned Deily wrote: > In article > , > > > > 7stud wrote: > > On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > > > I can't figure out a way to programatically set the encoding for > > > > sys.stdout. So where does that leave me? > > > > You should be setting the terminal enco

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread Ned Deily
In article , 7stud wrote: > On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > > I can't figure out a way to programatically set the encoding for > > > sys.stdout.  So where does that leave me? > > > > You should be setting the terminal encoding administratively, not > > programmatically. > > >

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread Stephen Hansen
> > > You should be setting the terminal encoding administratively, not > > programmatically. > > > > The terminal encoding has always been utf-8. It was not set > programmatically. > > It seems to me that python 3.1's string handling is broken. > Apparently, in python 3.1 I am unable to explicitl

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > I can't figure out a way to programatically set the encoding for > > sys.stdout.  So where does that leave me? > > You should be setting the terminal encoding administratively, not > programmatically. > The terminal encoding has always been utf-8.

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread Martin v. Löwis
> I can't figure out a way to programatically set the encoding for > sys.stdout. So where does that leave me? You should be setting the terminal encoding administratively, not programmatically. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 12:19 pm, Stefan Behnel wrote: > 7stud wrote: > > python 3.1 won't let me > > explicitly encode my unicode string > > Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail. > As you should be able to see in the python 3.1 example I posted, I did not encode the st

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread Stefan Behnel
7stud wrote: > python 3.1 won't let me > explicitly encode my unicode string Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail. > and python 3.1 implicitly does > the encoding with the wrong codec. That's not a Python problem, though. Your terminal is configured for U

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 9:56 am, "Martin v. Löwis" wrote: > > I don't understand why I'm getting an encode error in python 3.1. > > The default encoding is not relevant here at all. Look at > sys.stdout.encoding. > > Regards, > Martin Hi, Thanks for the response. I get US-ASCII for both 2.6 and 3.1: ===pyt

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread Martin v. Löwis
> I don't understand why I'm getting an encode error in python 3.1. The default encoding is not relevant here at all. Look at sys.stdout.encoding. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list