jau wrote: > Hi co-listers! > > I have been off Python for 2 years and now, that i'm used to Eclipse and > Java, I decided to start a project with Python to refresh skills this > time using Eclipse and TrueStudio. But now, two things can be occured > since the last time i used it. > > the first one, something concerning to the encoding has changed and i > haven't noticed it. > > the other one, when using Python from Eclipse i have to add any special > config lines at the begining of my Python files. > > if i have this hello world python "program" (i have to call it by > someway, hahaha) > > print "hello world" > > i get this output > > hello world > sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file > C:\Workspace\J&J\src\es\jau\main.py on line 2, but no encoding declared; > see http://www.python.org/peps/pep-0263.html for details > > the article mentioned above didn't explain so much for me. > > i doesn't look to be an error, but curiosity is bitting me... what's > really happening here? Do I need to do any special thing to avoid this?
The single print statement above should not trigger this warning. Are there any non-ASCII character in the file (perhaps comments?). If you use non-ASCII characters in python source files, you have to tell the interpreter which encoding you are using - otherwise funny things will happen. You have to find out which encoding Eclipse uses to save file (looks like iso-8859-1) and add the line # -*- coding: iso-8859-1 -*- at the top of the file. Python does not make any assumptions about the encoding beyond US-ASCII (perhaps it does, but it does not encourage taking advantage of this) - if you use anything else, then you'll have to declare it. This will be important, if you use unicode strings: u"stränge characters" Python must know the encoding of the file in order to decode the string literal into an unicode string. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list