Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-05 Thread Max M
Carl Banks wrote: Also, note that there are some encodings unrelated to Unicode. For example, try this: . >>> "abcd".encode("base64") This is an encoding between two byte strings. Yes. This can be especially nice when you need to use restricted charsets. I needed to use unicode objects as Zope ids

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Carl Banks
Skip Montanaro wrote: > I started to answer, then got confused when I read the docstrings for > unicode.encode and unicode.decode: [snip] It certainly is confusing. When I first started Unicoding, I pretty much stuck to Aahz's rule of thumb, without understanding this details, and still do that.

Re: Unicode universe (was Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30))

2005-01-04 Thread Walter Dörwald
Skip Montanaro wrote: aahz> Here's the stark simple recipe: when you use Unicode, you *MUST* aahz> switch to a Unicode-centric view of the universe. Therefore you aahz> encode *FROM* Unicode and you decode *TO* Unicode. Period. It's aahz> similar to the way floating point contami

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Thomas Heller
Max M <[EMAIL PROTECTED]> writes: > Thomas Heller wrote: > >> It seems also the error messages aren't too helpful: >> >"ä".encode("latin-1") >> Traceback (most recent call last): >> File "", line 1, in ? >> UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 0: >> ordinal n

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Max M
Thomas Heller wrote: It seems also the error messages aren't too helpful: "ä".encode("latin-1") Traceback (most recent call last): File "", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 0: ordinal not in range(128) Hm, why does the 'encode' call complain about

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Jp Calderone
On Tue, 04 Jan 2005 16:41:05 +0100, Thomas Heller <[EMAIL PROTECTED]> wrote: >Skip Montanaro <[EMAIL PROTECTED]> writes: > > > michele> BTW what's the difference between .encode and .decode ? > > > > I started to answer, then got confused when I read the docstrings for > > unicode.encode and u

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Max M
[EMAIL PROTECTED] wrote: uhm ... then there is a misprint in the discussion of the recipe; BTW what's the difference between .encode and .decode ? (yes, I have been living in happy ASCII-land until now ... ;) # -*- coding: latin-1 -*- # here i make a unicode string unicode_file = u'Some danish cha

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Thomas Heller
Skip Montanaro <[EMAIL PROTECTED]> writes: > michele> BTW what's the difference between .encode and .decode ? > > I started to answer, then got confused when I read the docstrings for > unicode.encode and unicode.decode: > > >>> help(u"\xe4".decode) > Help on built-in function decode:

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread michele . simionato
Stephan: > I'd rather use german_ae.encode('latin1') ^^ > which returns '\xe4'. uhm ... then there is a misprint in the discussion of the recipe; BTW what's the difference between .encode and .decode ? (yes, I have been living in happy ASCII-land until now ... ;) I should probably ask for an

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread michele . simionato
Yep, I did the same and got confused :-/ Michele -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode universe (was Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30))

2005-01-04 Thread Skip Montanaro
aahz> Here's the stark simple recipe: when you use Unicode, you *MUST* aahz> switch to a Unicode-centric view of the universe. Therefore you aahz> encode *FROM* Unicode and you decode *TO* Unicode. Period. It's aahz> similar to the way floating point contaminates ints. That's wh

Unicode universe (was Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30))

2005-01-04 Thread Aahz
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: > >BTW what's the difference between .encode and .decode ? >(yes, I have been living in happy ASCII-land until now ... ;) Here's the stark simple recipe: when you use Unicode, you *MUST* switch to a Unicode-centric view of the universe.

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Skip Montanaro
michele> BTW what's the difference between .encode and .decode ? I started to answer, then got confused when I read the docstrings for unicode.encode and unicode.decode: >>> help(u"\xe4".decode) Help on built-in function decode: decode(...) S.decode([encoding[,errors]])

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Stephan Diehl
On Tue, 04 Jan 2005 05:43:32 -0800, michele.simionato wrote: > Holger: > >> FWIW, i added the recipe back to the online cookbook. It's not > perfectly >> formatted but still useful, i hope. > >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361742 > > Uhm... on my system I get: > >

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread michele . simionato
Holger: > FWIW, i added the recipe back to the online cookbook. It's not perfectly > formatted but still useful, i hope. > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361742 Uhm... on my system I get: >>> german_ae = unicode('\xc3\xa4', 'utf8') >>> print german_ae # dunno if it wi

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread holger krekel
On Fri, Dec 31, 2004 at 19:18 +0100, Alex Martelli wrote: > Cameron Laird <[EMAIL PROTECTED]> wrote: >... > > Yippee! The martellibot promises to explain Unicode for Pythoneers. > > http://groups-beta.google.com/group/comp.lang.python/msg/6015a5a05c206712 > > Uh -- _did_ I? Eeep... I guess

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2004-12-31 Thread Alex Martelli
Cameron Laird <[EMAIL PROTECTED]> wrote: ... > Yippee! The martellibot promises to explain Unicode for Pythoneers. > http://groups-beta.google.com/group/comp.lang.python/msg/6015a5a05c206712 Uh -- _did_ I? Eeep... I guess I did... mostly, I was pointing to Holger Krekel's very nice recipe (

Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2004-12-30 Thread Cameron Laird
QOTW: "I found the discussion of unicode, in any python book I have, insufficient." -- Thomas Heller "If you develop on a Mac, ... Objective-C could come in handy. . . . PyObjC makes mixing the two languages dead easy and more convenient than indoor plumbing." -- Robert Kern Among other ac

Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2004-12-30 Thread Cameron Laird
QOTW: "I found the discussion of unicode, in any python book I have, insufficient." -- Thomas Heller "If you develop on a Mac, ... Objective-C could come in handy. . . . PyObjC makes mixing the two languages dead easy and more convenient than indoor plumbing." -- Robert Kern Among other ac