Neil Schemenauer wrote: > Also, I'm a little unclear on the purpose of the __unicode__ method. > If you can return unicode from __str__ then why would I want to > provide a __unicode__ method? Perhaps it is meant for objects that > can either return a unicode or a string representation depending on > what the caller prefers. I have a hard time imagining a use for > that. It's what unicode() returns: >>> class A: ... def __str__(self):return "1" ... def __unicode__(self): return u"2" ... >>> a=A() >>> str(a) '1' >>> unicode(a) u'2' str() is guaranteed to return a byte string; unicode() is guaranteed to return a unicode string. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4