PDA

View Full Version : Python in Eclipse in Intrepid : SyntaxError: Non-ASCII character



yeehi
March 30th, 2009, 06:22 PM
I try to run hello world, but using the
¨key causes a syntax error.

Is there some way I can reconfigure the character sets, perhaps for example to UTF, that will let Python use the
¨key?

-grubby
March 30th, 2009, 08:14 PM
As far as I know Python 2.5 has no support for that.

cmay
March 30th, 2009, 09:11 PM
#! /usr/bin/env python
#encoding:UTF-8
print" the '¨'"
print "the ¨¨ "
if it is this character it works on my machine this way . ubuntu 8.10 and the python version that is installed per default. if not then just ignore my post :)

yeehi
March 30th, 2009, 10:24 PM
I am glad your Python is working! :)

Where would I paste that php code?

The Cog
March 30th, 2009, 11:30 PM
These two lines:

#! /usr/bin/env python
#encoding:UTF-8
should be the first two lines of your python source code file.
The second line says what character encoding the source file is using.

yeehi
March 31st, 2009, 08:37 AM
Sorry, I don´t understand what the python source code file is. In which directory do I find that file?

Or is it the file containing the program that I am writing?

Arndt
March 31st, 2009, 02:51 PM
Sorry, I don´t understand what the python source code file is. In which directory do I find that file?

Or is it the file containing the program that I am writing?

I don't know in what context you want to use that character (in a string? as a command?) but I can use it in a string simply from the command line:


$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "apa¨hej"
>>> s
'apa\xc2\xa8hej'
>>> print s
apa¨hej
>>>

Does that work for you too? If not, there may be some difference in our environment variables.

Tony Flury
March 31st, 2009, 03:18 PM
Sorry, I don´t understand what the python source code file is. In which directory do I find that file?

Or is it the file containing the program that I am writing?

Yes - The "python source code file" is the file which contains the python program that you are writing.