This commit is contained in:
Eric V. Smith 2015-08-24 08:00:49 -04:00
parent e4bd0c9b1e
commit 9d28e9ee71
1 changed files with 6 additions and 6 deletions

View File

@ -309,7 +309,7 @@ cannot contain any newlines, for example::
SyntaxError: invalid syntax SyntaxError: invalid syntax
But note that this works, since the newline is removed from the But note that this works, since the newline is removed from the
string, and the spaces in from of the '1' are allowed in an string, and the spaces in front of the '1' are allowed in an
expression:: expression::
>>> f'{x+\ >>> f'{x+\
@ -325,7 +325,7 @@ code such as::
>>> width = 10 >>> width = 10
>>> precision = 4 >>> precision = 4
>>> value = decimal.Decimal('12.34567') >>> value = decimal.Decimal('12.34567')
>>> f'result: {value:{width}.{prevision}}' >>> f'result: {value:{width}.{precision}}'
'result: 12.35' 'result: 12.35'
Once expressions in a format specifier are evaluated (if necessary), Once expressions in a format specifier are evaluated (if necessary),
@ -467,7 +467,7 @@ $identifier or ${expression}.
While $identifier is no doubt more familiar to shell scripters and While $identifier is no doubt more familiar to shell scripters and
users of some other languages, in Python str.format() is heavily users of some other languages, in Python str.format() is heavily
used. A quick search of Python's standard library shows only a handful used. A quick search of Python's standard library shows only a handful
of uses of string.Template, but over 1000 uses of str.format(). of uses of string.Template, but hundreds of uses of str.format().
Another proposed alternative was to have the substituted text between Another proposed alternative was to have the substituted text between
\{ and } or between \{ and \}. While this syntax would probably be \{ and } or between \{ and \}. While this syntax would probably be
@ -483,7 +483,7 @@ Many people on the python-ideas discussion wanted support for either
only single identifiers, or a limited subset of Python expressions only single identifiers, or a limited subset of Python expressions
(such as the subset supported by str.format()). This PEP supports full (such as the subset supported by str.format()). This PEP supports full
Python expressions inside the braces. Without full expressions, some Python expressions inside the braces. Without full expressions, some
desirable usage would be forbidden:: desirable usage would be cumbersome. For example::
>>> f'Column={col_idx+1}' >>> f'Column={col_idx+1}'
>>> f'number of items: {len(items)}' >>> f'number of items: {len(items)}'
@ -618,8 +618,8 @@ Lambdas may be used inside of parens::
>>> f'{(lambda x: x*2)(3)}' >>> f'{(lambda x: x*2)(3)}'
'6' '6'
Future extensions: Future extensions
================== =================
By using another leading character (say, 'i'), we could extend this By using another leading character (say, 'i'), we could extend this
proposal to cover internationalization and localization. The idea is proposal to cover internationalization and localization. The idea is