473,666 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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".encod e('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 1872
On Apr 20, 7:54*pm, <alg...@droog.s df-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.s df-eu.orgescribió:
I used extensively python and now I find this mess with strings,
I can't even reproduce tutorial examples:
>>>"apfel".enco de('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.joelonsoftw are.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.sd f-eu.org wrote:
>
Hi,
I used extensively python and now I find this mess with strings,
I can't even reproduce tutorial examples:
>>>"apfel".enco de('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.s df-eu.orgwrote:
Hi,
I used extensively python and now I find this mess with strings,
I can't even reproduce tutorial examples:>>"apf el".encode('u tf-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('someth ing') 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.sd f-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
19001
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 any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
4
7081
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 application for metaclasses: making classes instantly aware of their subclasses. The context was that I needed a class hierarchy, and I wanted to be able to instantiate subclasses by calling the root class. Which exact subclass would be instantiated...
3
2990
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 waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
46
3276
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 step (-> Python 3) some time in the near future? Reinhold
137
7062
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 pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
23
3616
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 so-called pre-fix notation or algebraic notation. Algebraic notations have the concept of operators, meaning, symbols placed around arguments. In algebraic in-fix notation, different
3
2478
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 memory location is locked by DB and so it throws an 'unhandled exception'. Following is the code snippet from my application and now i dont wanna touch the basic design. Regards, UvT
0
1017
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
2158
by: Giampaolo Rodola' | last post by:
http://groups.google.com/group/python-dev2 It seems it no longer exists. What happened?
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.