What happened with python? messed strings?
Jason Scheirer
jason.scheirer at gmail.com
Sun Apr 20 15:57:35 EDT 2008
On Apr 20, 11:54 am, <alg... at droog.sdf-eu.org> wrote:
> Hi,
> I used extensively python and now I find this mess with strings,
> I can't even reproduce tutorial examples:>>> "apfel".encode('utf-8') (it was with umlaut)
>
> File "<stdin>", line 0
>
> ^
> SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1:
> ordinal not in range(128)
Two things: Mark the character encoding of your file ( read
http://www.python.org/doc/2.3/whatsnew/section-encodings.html ), and
then if that doesn't work try to .decode('something') your string
first with the appropriate codec, then you get a unicode object for
free and you don't need the .encode('utf-8'). Also read the slides at
http://farmdev.com/talks/unicode/ for some good information about
unicode in Python.
>
> Is there any good guide to this mess of codecs and hell ?
>
> python should have stayed at version 1.5, every single 'improvement'
> has been a mess. But this is the definitive hell.
It's true -- decorators, the class/type cleanup, properties, -= and
+=, list comprehensions, generators, distutils, and all the new
modules in the standard library are completely, entirely useless.
Python SHOULD have stayed at 1.5.
>
> thanks!
>
> --
> SDF-EU Public Access UNIX System -http://sdf-eu.org
More information about the Python-list
mailing list