473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

What happened with python? messed strings?


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)
>>>
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.

thanks!

--
SDF-EU Public Access UNIX System - http://sdf-eu.org
Jun 27 '08 #1
6 1856
On Apr 20, 7:54*pm, <alg...@droog.sdf-eu.orgwrote:
[...]
python should have stayed at version 1.5, every single 'improvement'
has been a mess. But this is the definitive hell.
You can still download Python 1.5.2 from python.org:

http://www.python.org/download/releases/1.5/

HTH

--
Arnaud

Jun 27 '08 #2
En Sun, 20 Apr 2008 15:54:20 -0300, <al****@droog.sdf-eu.orgescribió:
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)
>>>>
Is there any good guide to this mess of codecs and hell ?
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
<http://www.joelonsoftware.com/articles/Unicode.html>

Python Unicode Howto: <http://docs.python.org/dev/howto/unicode.html>
python should have stayed at version 1.5, every single 'improvement'
has been a mess. But this is the definitive hell.
Nobody forces you to use a newer version. You can download 1.5.2 from http://www.python.org/download/releases/1.5

--
Gabriel Genellina

Jun 27 '08 #3
al****@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)
>>>>
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.

thanks!
Basically you're not using ASCII encoding in your source text... You need to
define an encoding for your source if you're using german umlauts or other
fancy stuff.

See chapter 2.1.4 of the reference manual, and add e.g.

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

as first or second line to your script. Make sure your editor talks utf-8,
or use the encoding used by your editor. cp1552 is a good choice for
windows...

--
juergen 'pearly' perlinger
"It's hard to make new errors!"
Jun 27 '08 #4
On Apr 20, 11:54*am, <alg...@droog.sdf-eu.orgwrote:
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/whatsn...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

Jun 27 '08 #5
Juergen Perlinger wrote:
al****@droog.sdf-eu.org wrote:
[snip]
Basically you're not using ASCII encoding in your source text... You need
to define an encoding for your source if you're using german umlauts or
other fancy stuff.

See chapter 2.1.4 of the reference manual, and add e.g.

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

as first or second line to your script. Make sure your editor talks utf-8,
or use the encoding used by your editor. cp1552 is a good choice for
windows...
stupid me. cp1252, of course.
--
juergen 'pearly' perlinger
"It's hard to make new errors!"
Jun 27 '08 #6
Jason Scheirer wrote:
[snip]
>
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.
totally OT, but just a few personal observations:

1. Everything was better a few hundred years ago.

2. A fool with a tool is still a fool.
(just in general, all people present excused...)

3. Simple things tend to become complex. Complex things tend to break, even
when used properly. And it might be hard to use them properly if you don't
have the understanding.

4. Simplicity can be deceptive.
--
juergen 'pearly' perlinger
"It's hard to make new errors!"
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
4
by: Ruud de Jong | last post by:
The question I have is: how safe / future proof / portable is the use of the __subclasses__ method that exists for new-style classes? Background: I thought I had found an easy-to-understand...
3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
46
by: Reinhold Birkenfeld | last post by:
Hello, another Perl/Python question: the subject says it all. Perl is going to change dramatically to become a more powerful and easier to (read|write) language. Is Python taking a similar...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
3
by: ujjwaltrivedi | last post by:
Can I use any method to allocate /deallocate memory other than new/ delete operators? Actually the problem is while using delete operator in my ".sqc" files the application crashes. It seems the...
0
by: | last post by:
(top posting fixed; please keep discussion on this list) --- algaba@droog.sdf-eu.org escribió: <mailman.747.1208720919.17997.python-list@python.org> Which tutorial example?
3
by: Giampaolo Rodola' | last post by:
http://groups.google.com/group/python-dev2 It seems it no longer exists. What happened?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.