diff options
author | Guido van Rossum <guido@python.org> | 1994-04-21 10:32:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-04-21 10:32:28 (GMT) |
commit | 1738311dab01da9ed884bd3d9622ead932fc6905 (patch) | |
tree | 118f885798272629ccfd24e0611bc7d1e274d23e /Doc/libtypes.tex | |
parent | 590b289672f340f2d122c6d75f195949213974e8 (diff) | |
download | cpython-1738311dab01da9ed884bd3d9622ead932fc6905.zip cpython-1738311dab01da9ed884bd3d9622ead932fc6905.tar.gz cpython-1738311dab01da9ed884bd3d9622ead932fc6905.tar.bz2 |
Documented new built-in function vars().
Documented new formatting features: %s takes any type, and
'%(key)format' % dictionary.
Documented posixpath.expandvars().
Diffstat (limited to 'Doc/libtypes.tex')
-rw-r--r-- | Doc/libtypes.tex | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Doc/libtypes.tex b/Doc/libtypes.tex index be8d990..8c77e49 100644 --- a/Doc/libtypes.tex +++ b/Doc/libtypes.tex @@ -300,7 +300,9 @@ characters are understood: \%, c, s, i, d, u, o, x, X, e, E, f, g, G. Width and precision may be a * to specify that an integer argument specifies the actual width or precision. The flag characters -, +, blank, \# and 0 are understood. The size specifiers h, l or L may be -present but are ignored. The ANSI features \code{\%p} and \code{\%n} +present but are ignored. The \code{\%s} conversion takes any Python +object and converts it to a string using \code{str()} before +formatting it. The ANSI features \code{\%p} and \code{\%n} are not supported. Since Python strings have an explicit length, \code{\%s} conversions don't assume that \code{'\\0'} is the end of the string. @@ -309,6 +311,19 @@ For safety reasons, huge floating point precisions are truncated; \code{\%f} conversions for huge numbers are replaced by \code{\%g} conversions. All other errors raise exceptions. +If the right argument is a dictionary (or any kind of mapping), then +the formats in the string must have a parenthesized key into that +dictionary inserted immediately after the \code{\%} character, and +each format formats the corresponding entry from the mapping. E.g. +\begin{verbatim} + >>> count = 2 + >>> language = 'Python' + >>> print '%(language)s has %(count)03d quote types.' % vars() + Python has 002 quote types. + >>> +\end{verbatim} +In this case no * specifiers may occur in a format. + Additional string operations are defined in standard module \code{string} and in built-in module \code{regex}. \index{string} |