David Abrahams wrote:
> Oh, wow; I may well be doing that all over.  Is it possible to
> instruct Python to make that an error rather than silently succeeding
> to do something that I shouldn't do?

I'm not sure but I remember reading that in Python 2.5 it becomes a 
Warning...

>> The question is in what byte encoding to encode. It 
>> looks obvious to convert it into settings.DEFAULT_CHARSET since it's an 
>> encoding of all your output. However if you set DEFAULT_CHARSET into 
>> some legacy encoding (i.e. other than 'utf-8') 
> 
> I don't set it to anything explicitly, so I have the default
> DEFAULT_CHARSET.

Then it's 'utf-8' which is how it should be anyway :-)

> Well, that's very instructive, thank you!  But again, my main concern
> is that I'm probably doing something bad all over, by combining byte
> strings with unicode strings.

Implicit combining is bad, yes. Explicit conversions are now required if 
you do some fancy string staff (uppercasing, lowercasing, getting 
length). If all you do is concatenation then it will work for byte 
strings without conversion. This is why I suggested it: your code seems 
to only do concatenation.

In some future (after hassle with current branches is over) Django will 
do automatic decoding of input bytes into unicode strings and apps will 
work with them exclusively.

> By the way, is there a reference that describes Python's string
> abstractions?

This one is good: http://docs.python.org/lib/encodings-overview.html

> I take it from your use of the terms "unicode string"
> and "byte string" that they are not in fact congruent to one another.
> Let me guess: a byte string (e.g. 'abcdef') is a semantically void
> container of bytes that might be used for ascii, utf-8, or something
> else... and a "unicode string" is a container of code points?

Yes, pretty much.

Byte strings are encoded representation intended for serialization, 
storing, transferring. Unicode strings are code points in the form of 2 
or 4 bytes digits (the latter is more common in todays Python 
installations) intended for working with actual letters.

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to