Re: UnicodeEncodeError during repr()
- From: gb345 <gb345@xxxxxxxxxxx>
- Date: Mon, 19 Apr 2010 17:08:19 +0000 (UTC)
In <hqguja$tt$1@xxxxxxxxx> "Martin v. Loewis" <martin@xxxxxxxxxxx> writes:
Do I need to do something especial to get repr to work strictly
with unicode?
Yes, you need to switch to Python 3 :-)
Or should __repr__ *always* return bytes rather than unicode?
In Python 2.x: yes.
What about __str__ ?
Likewise.
If both of these are supposed to return bytes,
then what method should I use to define the unicode representation
for instances of a class?
__unicode__.
Thanks!
.
- Follow-Ups:
- Re: UnicodeEncodeError during repr()
- From: Dave Angel
- Re: UnicodeEncodeError during repr()
- References:
- UnicodeEncodeError during repr()
- From: gb345
- Re: UnicodeEncodeError during repr()
- From: Martin v. Loewis
- UnicodeEncodeError during repr()
- Prev by Date: "ssl" module doesn't validate that domain of certificate is correct
- Next by Date: scipy error undefined symbol: lsame_
- Previous by thread: Re: UnicodeEncodeError during repr()
- Next by thread: Re: UnicodeEncodeError during repr()
- Index(es):