A
anuraguniyal
#how can I print a list of object which may return unicode
representation?
# -*- coding: utf-8 -*-
class A(object):
def __unicode__(self):
return u"©au"
__str__ = __repr__ = __unicode__
a = A()
try:
print a # doesn't work?
except UnicodeEncodeError,e:
print e
try:
print unicode(a) # works, ok fine, great
except UnicodeEncodeError,e:
print e
try:
print unicode([a]) # what!!!! doesn't work?
except UnicodeEncodeError,e:
print e
"""
Now how can I print a list of object which may return unicode
representation?
loop/map is not an option as it goes much deepr in my real code
any can anyoen explain what is happening here under the hood?
"""
representation?
# -*- coding: utf-8 -*-
class A(object):
def __unicode__(self):
return u"©au"
__str__ = __repr__ = __unicode__
a = A()
try:
print a # doesn't work?
except UnicodeEncodeError,e:
print e
try:
print unicode(a) # works, ok fine, great
except UnicodeEncodeError,e:
print e
try:
print unicode([a]) # what!!!! doesn't work?
except UnicodeEncodeError,e:
print e
"""
Now how can I print a list of object which may return unicode
representation?
loop/map is not an option as it goes much deepr in my real code
any can anyoen explain what is happening here under the hood?
"""