This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek, docs@python
Date 2012-09-16.19:59:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1347825591.49.0.625826586182.issue15952@psf.upfronthosting.co.za>
In-reply-to
Content
format(value) and value.__format__() behave differently even though the documentation says otherwise:

"Note: format(value, format_spec) merely calls value.__format__(format_spec)."

(from http://docs.python.org/library/functions.html?#format )

The difference happens when the format string is unicode.  For example:

>>> format(10, u'n')
u'10'
>>> (10).__format__(u'n')  # parentheses needed to prevent SyntaxError
'10'

So either the documentation should be changed, or the behavior should be changed to match.

Related to this: neither the "Format Specification Mini-Language" documentation nor the string.Formatter docs seem to say anything about the effect that a unicode format string should have on the return value (in particular, should it cause the return value to be unicode or not):

http://docs.python.org/library/string.html#formatspec
http://docs.python.org/library/string.html#string-formatting

See also issue 15276 (int formatting), issue 15951 (empty format string), and issue 7300 (unicode arguments).
History
Date User Action Args
2012-09-16 19:59:51chris.jerdoneksetrecipients: + chris.jerdonek, docs@python
2012-09-16 19:59:51chris.jerdoneksetmessageid: <1347825591.49.0.625826586182.issue15952@psf.upfronthosting.co.za>
2012-09-16 19:59:50chris.jerdoneklinkissue15952 messages
2012-09-16 19:59:50chris.jerdonekcreate