Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Problem with __str__ method and character encoding

Reply
Thread Tools

Re: Problem with __str__ method and character encoding

 
 
Chris Angelico
Guest
Posts: n/a
 
      12-07-2012
On Sat, Dec 8, 2012 at 1:14 AM, gialloporpora <(E-Mail Removed)> wrote:
>>>> print a

> UnicodeError
>>>> print a.__str__()

> OK


By the way, it's *much* more helpful to copy and paste the actual
error message and output, rather than retyping like that. Spending one
extra minute in the interactive interpreter before you post can save
us all a lot of time and confusion. In this case, what I'm seeing is
(Python 2.6):

>>> print a


Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
print a
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 27: ordinal not in range(12

Which has quite a bit of handy information in it.

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Problem with __str__ method and character encoding peter Python 0 12-07-2012 02:22 PM
substitution __str__ method of an instance netimen Python 5 10-23-2008 09:49 PM
cpython list __str__ method for floats [david] Python 6 09-12-2007 11:48 PM
Re: "Aliasing" an object's __str__ to a different method Jeffrey E. Forcier Python 2 07-24-2005 02:25 PM
"Aliasing" an object's __str__ to a different method Jeffrey E. Forcier Python 7 07-24-2005 12:45 AM



Advertisments