[Tutor] symbol encoding and processing problem

Timmie timmichelsen at gmx-topmail.de
Fri Oct 19 16:49:39 CEST 2007

> > I still don't know why there is such a encoding mess on Python. For me
> this
> > totally neglects the statement that python code is easily portable or
> executable
> > on other platforms.
> I don't think this is entirely fair. For example at the start you had a 
> file containing cp1252 data but told Python it was utf-8. You can't 
> really expect Python to just do the right thing in such circumstances.
Here you are right. I was (without knowing it) doeing the wrong thing.
Well, my judgement was based on a confusion that I haven't been able to clear so

At first my file was encoded differently than the python default encoding and I
coded even a different encoding in the file head. After I'd adaped all this
correctly my code worked well.
I tried to use the same code interactively on the IPython shell. As I said from
my previous post, the shell uses again a different encoding. Therefore, the same
code that worked well from file did fail. When I found out that I could set the
default encoding to UTF-8 you warned me of a lesser portability.
I am totally lost:
* python has ascii as default encoding
* my linux uses UTF-8 (therefore all files created on linux are UTF-8)
* windows uses cp1250
* IPtyhon something else: on the machine where I am currently on stdin is set to

So what encoding to I use to display and process characters that exeeed the
standard english alphabet?

> Does you IDL code include non-ascii characters? Perhaps you would do 
> better if you stuck with ascii for your Python source code, too - there 
> is no need to include non-ascii characters directly, you can use \x 
> string escapes to insert them into your strings.
My initial question was:

1) get a coordinate (DEG° MIN' SEC'') as input from user via easygui
2) split that string into its subscripts: degrees, minutes and secons
3) do some processing of the 3 varaibles
4) print the output with easygui.

I am not really interested which is the best encoding. I want to know:
* how I do this that I don't get a encoding error?
* how do I code it that the code runs on linux and windows
from file and in IPython

Thanks again for your support. I don't want any misunderstandings. You were a
good tutor to me and are helping
patiently many user stepping into python.

Kind regards,

More information about the Tutor mailing list