Re: [Tutor] unicode help

2012-11-14 Thread Sander Sweers
Marilyn Davis schreef op wo 14-11-2012 om 13:23 [-0800]: > I found this site: > http://hints.macworld.com/article.php?story=20100713130450549 > > and that fixes it. Short answer: It is not a fix but a workaround. Try: print symbol.encode('utf-8') Longer answer: It is not really a fix, it is a wo

Re: [Tutor] unicode help

2012-11-14 Thread Dave Angel
On 11/14/2012 04:07 PM, Marilyn Davis wrote: > > > Goodness! I didn't expect it to be a Mac thing. > > So, on a Windows machine, running Python 2.6.6, sys.stdout.encoding is > 'cp1252', yet the code runs fine. > > On Ubuntu with 2.7, it's 'UTF-8' and it runs just fine. > > I find this most myste

Re: [Tutor] unicode help

2012-11-14 Thread Marilyn Davis
On Wed, November 14, 2012 1:07 pm, Marilyn Davis wrote: > Thank you, Dave, for looking at my problem, and for correcting me on my > top posting. > > See below: > > > On Wed, November 14, 2012 12:34 pm, Dave Angel wrote: > > >> On 11/14/2012 03:10 PM, Marilyn Davis wrote: >> >> >>> Hi, >>> >>> >>>

Re: [Tutor] unicode help

2012-11-14 Thread Marilyn Davis
Thank you, Dave, for looking at my problem, and for correcting me on my top posting. See below: On Wed, November 14, 2012 12:34 pm, Dave Angel wrote: > On 11/14/2012 03:10 PM, Marilyn Davis wrote: > >> Hi, >> >> >> Last year, I was helped so that this ran nicely on my 2.6: >> >> >> #! /usr/bin/e

Re: [Tutor] unicode help

2012-11-14 Thread Dave Angel
On 11/14/2012 03:10 PM, Marilyn Davis wrote: > Hi, > > Last year, I was helped so that this ran nicely on my 2.6: > > #! /usr/bin/env python > # -*- coding: utf-8 -*- > # necessary for python not to complain about "¥" > > symbol = unichr(165) > print unicode(symbol) > > --- end of code --- > > But,

Re: [Tutor] unicode help

2012-11-14 Thread Marilyn Davis
Hi, Last year, I was helped so that this ran nicely on my 2.6: #! /usr/bin/env python # -*- coding: utf-8 -*- # necessary for python not to complain about "¥" symbol = unichr(165) print unicode(symbol) --- end of code --- But, now on my 2.7, and on 2.6 when I tried reinstalling it, I get: bas

Re: [Tutor] unicode help

2011-05-28 Thread Marilyn Davis
Aye, thank you. I do like that syntax better. Sometimes it's time to just quit and try again later when I'm not so frustrated. That's when I make silly bugs. But, we got it! Thank you again. I think it's a nifty hack. M On Sat, May 28, 2011 3:53 pm, Alexandre Conrad wrote: > Marilyn, > >

Re: [Tutor] unicode help

2011-05-28 Thread Alexandre Conrad
Marilyn, You miss-typed the line, it should have a semicolon right after the word "coding", such as: # coding: utf-8 not # coding utf-8 as you showed from your file. The syntax suggested syntax # -*- coding: utf8 -*- by Martin is equivalent, but I always have a hard time remembering it from t

Re: [Tutor] unicode help

2011-05-28 Thread Marilyn Davis
Thank you Martin, This: #!/usr/bin/env python # -*- coding: utf8 -*- '''Unicode handling for 2.6. ''' [rest of module deleted] produces an emacs warning: Warning (mule): Invalid coding system `utf8' is specified for the current buffer/file by the :coding tag. It is highly recommended to fix it

Re: [Tutor] unicode help

2011-05-28 Thread Marilyn Davis
Thank you Alexandre for your quick reply. I tried your suggestion (again) and I still get: ./uni.py File "./uni.py", line 20 SyntaxError: Non-ASCII character '\xa5' in file ./uni.py on line 21, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Can you suggest a

Re: [Tutor] unicode help

2011-05-28 Thread Martin A. Brown
Hello there, : I'm still on Python 2.6 and I'm trying to work some unicode : handling. : : I've spent some hours on this snippet of code, trying to follow : PEP 0263, since the error tells me to see it. I've tried other : docs too and I am still clueless. OK, so this is PEP 0263. htt

Re: [Tutor] unicode help

2011-05-28 Thread Alexandre Conrad
When Python loads your file from your file system, it assumes all characters in the file are ASCII. But when it hits non-ASCII characters (currency symbols), Python doesn't know how to interpret it. So you can give Python a hint by putting at the top of your file the encoding of your file: After t

[Tutor] unicode help

2011-05-28 Thread Marilyn Davis
Hi, I'm still on Python 2.6 and I'm trying to work some unicode handling. I've spent some hours on this snippet of code, trying to follow PEP 0263, since the error tells me to see it. I've tried other docs too and I am still clueless. The code works, except for the comment at the end. I would

Re: [Tutor] unicode help (COM)

2004-12-05 Thread Kent Johnson
Rene Bourgoin wrote: Thanks for the responses. i'm a non-programmer and was learning/playing with some pyhton COM . I'm trying to get my resluts from an excel spreadsheet to be saved or printed or stored as a python string. when i run this the results are in unicode. What problem are the unic