John J Lee wrote: > Is this a bug? I don't believe so - the string formatting documentation states that the result will be unicode if either the format string is unicode or any of the objects passed to a %s format code is unicode. That latter part has just been extended to include any object that returns Unicode from __str__, instead of being restricted to actual Unicode instances. Note that the following behaves the same way regardless of whether you use 2.4 or 2.5: "%s" % 'hi' "%s" % u'hi' And once the result has been promoted to unicode, __unicode__ is used directly: >>> print repr("%s%s" % (a(), a())) __str__ accessing <__main__.a object at 0x00AF66F0>.__unicode__ __str__ accessing <__main__.a object at 0x00AF6390>.__unicode__ __str__ u'hihi' Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
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