On Sat, Sep 19, 2009 at 3:07 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Sep 19, 2009 at 11:51 AM, Joshua Russo <josh.r.ru...@gmail.com>wrote:
>
>> Just one other thing. I was under the impression that x = u''
>> is equivalent to x = Unicode(''). Is that not correct?  Seeing as you seem
>> to be indicating a difference between the unicode object and a literal.
>>
>>
>>
> Note you could answer that yourself by changing the:
>
> u = u'¿Chapter?'
>
> in the program I posted to:
>
> u = unicode('¿Chapter?')
>
> and seeing what happens.
>
> The answer is they are not equivalent.  The unicode literal form will make
> use of the file's encoding declaration to know the correct encoding of the
> source bytes, the other cannot.  The other contains a bytestring.  The
> source file encoding declaration has no effect on bytestrings in the source,
> so Python will not be able to convert the bytestring version to unicode as
> it will by default attempt to use the ascii codec for the conversion, and
> that will fail.
>

Ok, thanks, I think I got it now. :o)

>
>

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to