summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-05-11 17:47:27 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-05-11 17:47:27 (GMT)
commit30439b23c08761a8356cec23a4a8ff09bba35414 (patch)
tree957f0fc8d4739f7df7c079c945f1bd31f4f79912 /Doc
parent57e6eac9056982bc6f4f18da0b6efacd1a19e3ae (diff)
downloadcpython-30439b23c08761a8356cec23a4a8ff09bba35414.zip
cpython-30439b23c08761a8356cec23a4a8ff09bba35414.tar.gz
cpython-30439b23c08761a8356cec23a4a8ff09bba35414.tar.bz2
Document default fmtspec. Fix inaccurate note. Document exceptions.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/functions.rst13
1 files changed, 8 insertions, 5 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 3020128..8b7eef5 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -498,11 +498,14 @@ are always available. They are listed here in alphabetical order.
of the *value* argument, however there is a standard formatting syntax that
is used by most built-in types: :ref:`formatspec`.
- .. note::
-
- ``format(value, format_spec)`` merely calls
- ``value.__format__(format_spec)``.
-
+ The default *format_spec* is an empty string which usually gives the same
+ effect as calling ``str(value)``.
+
+ A call to ``format(value, format_spec)`` is translated to
+ ``type(value).__format__(format_spec)`` which bypasses the instance
+ dictionary when searching for the value's :meth:`__format__` method. A
+ :exc:`TypeError` exception is raised if the method is not found or if either
+ the *format_spec* or the return value are not strings.
.. function:: frozenset([iterable])
:noindex: