John J Lee <[EMAIL PROTECTED]> wrote:
> The note (4) says that the result will be unicode, but it doesn't say how, 
> in this case, that comes about.  This case is confusing because the docs 
> claim string formatting with %s "converts ... using str()", and yet 
> str(a()) returns a bytestring.  Does it *really* use str, or just __str__? 
> Surely the latter? (given the observed behaviour, and not reading the C 
> source)

It uses __str__ and confirms that the returned object is a 'str' or
'unicode'.  The docs are not precise but they were not for 2.4
either.  Note the following case:

    '%s' % u'Hello!'

The operand is not forced to be a str.

  Neil

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to