Why does the "".join(r) do this?

Peter Otten __peter__ at web.de
Thu May 20 17:13:29 EDT 2004


John Roth wrote:

> "Ivan Voras" <ivoras at __geri.cc.fer.hr> wrote in message
> news:c8itrm$epg$1 at bagan.srce.hr...

>> Is there a way to change the default codec in a part of a program?
>> (Meaning that different parts of program deal with strings they know are
>> in a specific different code pages?)
> 
> Does the encoding line (1st or second line of program) do this?
> I don't remember if it does or not - although I'd suspect not.
> Otherwise it seems like a reasonably straightforward function
> to write.

As a str does not preserve information about the encoding, the
# -*- coding: XXX -*-
comment does not help here. It does however control the decoding of unicode
strings. I suppose using unicode for non-ascii literals plus the above
coding comment is as close as you can get to the desired effect.

With some more work you could probably automate string conversion like it is
done with quixote's htmltext. Not sure if that would be worth the effort,
though.

Peter




More information about the Python-list mailing list