Re: Printing Unicode strings in a list

2022-04-30 Thread Chris Angelico
On Sun, 1 May 2022 at 00:03, Vlastimil Brom wrote: > (Even the redundant u prefix from your python2 sample is apparently > accepted, maybe for compatibility reasons.) Yes, for compatibility reasons. It wasn't accepted in Python 3.0, but 3.3 re-added it to make porting easier. It doesn't do anythi

Re: Printing Unicode strings in a list

2022-04-30 Thread Vlastimil Brom
čt 28. 4. 2022 v 13:33 odesílatel Stephen Tucker napsal: > > Hi PythonList Members, > > Consider the following log from a run of IDLE: > > == > > Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] > on win32 > Type "copyright", "credits" or "license()" for m

Re: Printing Unicode strings in a list

2022-04-28 Thread Rob Cliffe via Python-list
On 28/04/2022 14:27, Stephen Tucker wrote: To Cameron Simpson, Thanks for your in-depth and helpful reply. I have noted it and will be giving it close attention when I can. The main reason why I am still using Python 2.x is that my colleagues are still using a GIS system that has a Python pro

Re: Printing Unicode strings in a list

2022-04-28 Thread Jon Ribbens via Python-list
On 2022-04-28, Stephen Tucker wrote: > Hi PythonList Members, > > Consider the following log from a run of IDLE: > >== > > Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] > on win32 > Type "copyright", "credits" or "license()" for more information. p

Re: Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
To Cameron Simpson, Thanks for your in-depth and helpful reply. I have noted it and will be giving it close attention when I can. The main reason why I am still using Python 2.x is that my colleagues are still using a GIS system that has a Python programmer's interface - and that interface uses P

Re: Printing Unicode strings in a list

2022-04-28 Thread Cameron Simpson
On 28Apr2022 12:32, Stephen Tucker wrote: >Consider the following log from a run of IDLE: >== > >Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] >on win32 >Type "copyright", "credits" or "license()" for more information. print (u"\u2551") >║ pri

Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
Hi PythonList Members, Consider the following log from a run of IDLE: == Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> print (u"\u2551") ║ >>> print ([u"\u2551"]) [u'\u2551'

Re: the official way of printing unicode strings

2008-12-14 Thread Martin v. Löwis
icial way of printing > unicode strings. I mean, the question is not "how can I print the unicode > string" but "how the creators of the language suppose me to print the > unicode string". I couldn't find an answer to this question in docs, so I > hope somebody

Re: the official way of printing unicode strings

2008-12-14 Thread Ben Finney
on way of > printing unicode strings? Try these: http://effbot.org/zone/unicode-objects.htm> http://www.reportlab.com/i18n/python_unicode_tutorial.html> http://www.amk.ca/python/howto/unicode> If you want something more official, try the PEP that introduced Unicode object

Re: the official way of printing unicode strings

2008-12-14 Thread J. Clifford Dyer
ally doing like that saves many problems. > Especially in Python, where there is one official way to do any elementary > task. And I just want to know what is the normal, official way of printing > unicode strings. I mean, the question is not "how can I print the unicode > string"

Re: the official way of printing unicode strings

2008-12-14 Thread Piotr Sobolewski
k. And I just want to know what is the normal, official way of printing unicode strings. I mean, the question is not "how can I print the unicode string" but "how the creators of the language suppose me to print the unicode string". I couldn't find an answer to this question in

Re: the official way of printing unicode strings

2008-12-14 Thread Marc 'BlackJack' Rintsch
On Sun, 14 Dec 2008 06:48:19 +0100, Piotr Sobolewski wrote: > Then I tried to do this that way: > sys.stdout = codecs.getwriter("utf-8")(sys.__stdout__) > s = u"Stanisław Lem" > print u > This works but is even more combersome. > > So, my question is: what is the official, recommended Python way?

the official way of printing unicode strings

2008-12-13 Thread Piotr Sobolewski
Hello, in Python (contrary to Perl, for instance) there is one way to do common tasks. Could somebody explain me what is the official python way of printing unicode strings? I tried to do this such way: s = u"Stanisław Lem" print u.encode('utf-8') This works, but is very

Re: printing unicode strings

2007-07-24 Thread 7stud
Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: printing unicode strings

2007-07-24 Thread John Machin
On Jul 25, 6:56 am, 7stud <[EMAIL PROTECTED]> wrote: > Can anyone tell me why I can print out the individual variables in the > following code, but when I print them out combined into a single > string, I get an error? > > symbol = u'ibm' > price = u'4 \xbd' # 4 1/2 > > print "%s" % symbol > print

Re: printing unicode strings

2007-07-24 Thread Peter Otten
7stud wrote: > Can anyone tell me why I can print out the individual variables in the > following code, but when I print them out combined into a single > string, I get an error? > > symbol = u'ibm' > price = u'4 \xbd' # 4 1/2 > > print "%s" % symbol > print "%s" % price.encode("utf-8") > print

printing unicode strings

2007-07-24 Thread 7stud
Can anyone tell me why I can print out the individual variables in the following code, but when I print them out combined into a single string, I get an error? symbol = u'ibm' price = u'4 \xbd' # 4 1/2 print "%s" % symbol print "%s" % price.encode("utf-8") print "%s %s" % (symbol, price.encode("

Re: WTF? Printing unicode strings

2006-05-21 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: > Learn something every day. I take it "646" is an alias for "ascii" (or vice > versa)? Usage of "646" as an alias for ASCII is primarily a Sun invention. When ASCII became an international standard, its standard number became ISO/IEC 646:1968. It's not *quite* the same a

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Serge Orlov wrote: > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > > > Ron Garret wrote: > > > > > > > I'm using an OS X terminal to ssh to a Linux mach

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > > > > > In theor

Re: WTF? Printing unicode strings

2006-05-19 Thread Robert Kern
[EMAIL PROTECTED] wrote: > Robert> Because sys.stdout.encoding isn't determined by your Python > Robert> configuration, but your terminal's. > > Learn something every day. I take it "646" is an alias for "ascii" (or vice > versa)? > > % python > Python 2.4.2 (#1, Feb 23 2006, 12:

Re: WTF? Printing unicode strings

2006-05-19 Thread John Salerno
[EMAIL PROTECTED] wrote: > John> Hmm, not that this helps me any :) > > import sys > sys.stdout.encoding > John> 'cp1252' > > Sure it does. You can print Unicode objects which map to cp1252. I assume > that means you're on Windows or that for some perverse reason you h

Re: WTF? Printing unicode strings

2006-05-19 Thread skip
John> Hmm, not that this helps me any :) import sys sys.stdout.encoding John> 'cp1252' Sure it does. You can print Unicode objects which map to cp1252. I assume that means you're on Windows or that for some perverse reason you have your Mac's Terminal window set to cp

Re: WTF? Printing unicode strings

2006-05-19 Thread John Salerno
[EMAIL PROTECTED] wrote: > Robert> Because sys.stdout.encoding isn't determined by your Python > Robert> configuration, but your terminal's. > > Learn something every day. I take it "646" is an alias for "ascii" (or vice > versa)? Hmm, not that this helps me any :) >>> import sys >>>

Re: WTF? Printing unicode strings

2006-05-19 Thread skip
Robert> Because sys.stdout.encoding isn't determined by your Python Robert> configuration, but your terminal's. Learn something every day. I take it "646" is an alias for "ascii" (or vice versa)? % python Python 2.4.2 (#1, Feb 23 2006, 12:48:31) [GCC 3.4.1] on sunos5 Typ

Re: WTF? Printing unicode strings

2006-05-19 Thread Robert Kern
John Salerno wrote: > AFAIK, I'm all ASCII (at least, I never made explicit changes to the > default Python install), so how am I able to print out the character? Because sys.stdout.encoding isn't determined by your Python configuration, but your terminal's. -- Robert Kern "I have come to bel

Re: WTF? Printing unicode strings

2006-05-19 Thread John Salerno
Fredrik Lundh wrote: > Ron Garret wrote: > > u'\xbd' >> u'\xbd' > print _ >> Traceback (most recent call last): >> File "", line 1, in ? >> UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in >> position 0: ordinal not in range(128) > > so stdout on your machine is asci

Re: WTF? Printing unicode strings

2006-05-19 Thread Laurent Pointal
Ron Garret a écrit : > In article <[EMAIL PROTECTED]>, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> Ron Garret wrote: >> >> u'\xbd' >>> u'\xbd' >> print _ >>> Traceback (most recent call last): >>> File "", line 1, in ? >>> UnicodeEncodeError: 'ascii' codec can't encode character u'\

Re: WTF? Printing unicode strings

2006-05-19 Thread Serge Orlov
Serge Orlov wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > > > > > In theory it should work out of the box. OS X terminal should se

Re: WTF? Printing unicode strings

2006-05-19 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > > > In theory it should work out of the box. OS X terminal should set > > > > enviromental variable LAN

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > In theory it should work out of the box. OS X terminal should set > > > enviromental variable LANG=en_US.utf-8, then ssh should tr

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > In theory it should work out of the box. OS X terminal should set > > enviromental variable LANG=en_US.utf-8, then ssh should transfer this > > variable to Linux and python will know that your terminal is utf-8. >

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > In article <[EMAIL PROTECTED]>, > > > > Robert Kern <[EMAIL PROTECTED]> wrote: > > >

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > >>Ron Garret wrote: >> >>>I'm using an OS X terminal to ssh to a Linux machine. >> >>Click on the "Terminal" menu, then "Window Settings...". Choose "Display" >>from >>the combobox. At the bottom you w

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > > > Ron Garret wrote: > > > > > > > > > I forgot to mention: > > > > > > > > > sy

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > Click on the "Terminal" menu, then "Window Settings...". Choose "Display" > from > the combobox. At the bottom you will see a combobox titl

Re: WTF? Printing unicode strings

2006-05-18 Thread Paul Boddie
Ron Garret wrote: > > But what about this: > > >>> f2=open('foo','w') > >>> f2.write(u'\xFF') > Traceback (most recent call last): > File "", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in > position 0: ordinal not in range(128) > >>> > > That should have nothi

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > I'm using an OS X terminal to ssh to a Linux machine. Click on the "Terminal" menu, then "Window Settings...". Choose "Display" from the combobox. At the bottom you will see a combobox title "Character Set Encoding". Choose "Unicode (UTF-8)". > But what about this: > f2=

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > > I forgot to mention: > > > > > > > sys.getdefaultencoding() > > > > > > > > 'u

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > > > I forgot to mention: > > > > > sys.getdefaultencoding() > > > > > > 'utf-8' > > > > A) You shouldn't be able to do that. > > What can I say? I can. > > > B) Don't do

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > >>Ron Garret wrote: >> >>>I forgot to mention: >>> >>> >>sys.getdefaultencoding() >>> >>>'utf-8' >> >>A) You shouldn't be able to do that. > > What can I say? I can. See B). >>B) Don't do that.

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I forgot to mention: > > > sys.getdefaultencoding() > > > > 'utf-8' > > A) You shouldn't be able to do that. What can I say? I can. > B) Don't do that. OK. What should I do instead? > C)

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > I forgot to mention: > sys.getdefaultencoding() > > 'utf-8' A) You shouldn't be able to do that. B) Don't do that. C) It's not relevant to the encoding of stdout which determines how unicode strings get converted to bytes when printing them: >>> import sys >>> sys.stdou

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > u'\xbd' > > u'\xbd' > print _ > > Traceback (most recent call last): > > File "", line 1, in ? > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in > > position 0: ord

Re: WTF? Printing unicode strings

2006-05-18 Thread Fredrik Lundh
Ron Garret wrote: u'\xbd' > u'\xbd' print _ > Traceback (most recent call last): > File "", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in > position 0: ordinal not in range(128) so stdout on your machine is ascii, and you don't understand why you

Re: WTF? Printing unicode strings

2006-05-18 Thread John Salerno
Ron Garret wrote: u'\xbd' > u'\xbd' print _ > Traceback (most recent call last): > File "", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in > position 0: ordinal not in range(128) Not sure if this really helps you, but: >>> u'\xbd' u'\xbd' >>> pri

WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
>>> u'\xbd' u'\xbd' >>> print _ Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 0: ordinal not in range(128) >>> -- http://mail.python.org/mailman/listinfo/python-list