unicode bit me

anuraguniyal at yahoo.com anuraguniyal at yahoo.com
Sun May 10 00:21:22 EDT 2009


and yes replace string by u'\N{COPYRIGHT SIGN}au'
as mentioned earlier non-ascii char may not come correct posted here.

On May 10, 9:19 am, "anuraguni... at yahoo.com" <anuraguni... at yahoo.com>
wrote:
> First of all thanks everybody for putting time with my confusing post
> and I apologize for not being clear after so many efforts.
>
> here is my last try (you are free to ignore my request for free
> advice)
>
> # -*- coding: utf-8 -*-
>
> class A(object):
>
>     def __unicode__(self):
>         return u"©au"
>
>     def __repr__(self):
>         return unicode(self).encode("utf-8")
>
>     __str__ = __repr__
>
> a = A()
> u1 = unicode(a)
> u2 = unicode([a])
>
> now I am not using print so that doesn't matter stdout can print
> unicode or not
> my naive question is line u2 = unicode([a]) throws
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
> 1: ordinal not in range(128)
>
> shouldn't list class call unicode on its elements? I was expecting
> that
> so instead do i had to do this
> u3 = "["+u",".join(map(unicode,[a]))+"]"




More information about the Python-list mailing list