[Tutor] Unicode in List Object

Andre Engels andreengels at gmail.com
Mon Mar 26 17:24:15 CEST 2007


2007/3/26, Roman Kreuzhuber <rkreuzhuber at hotmail.com>:
>
> Thanks for the quick response!
> I see! Oh I didn't realize that it's not the list which raises an error.
> For a test I tried to insert a string containing a unicode character as
> follows:
>
> ListObject = []
> ListObject.insert(0,u"Möälasdji")
>
> which raises: "SyntaxError: Non-ASCII character '\xfc' in file C:\python
> proj\lists\main.py on line 48, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details"


At the top of your Python file, below the line which might be there that
reads

#!/usr/bin/python

but above any other line, add:

# -*- coding: utf-8  -*-

This tells the parser that this file should be read as unicode.

-- 
Andre Engels, andreengels at gmail.com
ICQ: 6260644  --  Skype: a_engels
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070326/31f2449c/attachment.html 


More information about the Tutor mailing list