[issue21547] '!s' formatting documentation bug

Eric V. Smith report at bugs.python.org
Wed May 21 16:21:36 CEST 2014


Eric V. Smith added the comment:

I suggest using whatever language explains what "u'%s' %obj" does. It's the same behavior.

>From the SO question, given:

class A(object):
    def __str__(self):
        return 'as str'

    def __unicode__(self):
        return u'as unicode'

Then:

>>> '%s' % A()
'as str'
>>> u'%s' % A()
u'as unicode'

and:

>>> '{!s}'.format(A())
'as str'
>>> u'{!s}'.format(A())
u'as unicode'

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21547>
_______________________________________


More information about the Python-bugs-list mailing list