Updates to PEP 3101 as a result of discussion in Python-3000

This commit is contained in:
Talin 2006-07-05 00:51:40 +00:00
parent 358f324037
commit 2c29fb9bd0
1 changed files with 20 additions and 17 deletions

View File

@ -169,12 +169,12 @@ Conversion Specifiers
"My name is {0:8}".format('Fred')
The meaning and syntax of the conversion specifiers depends on the
type of object that is being formatted, however many of the
built-in types will recognize a standard set of conversion
specifiers.
type of object that is being formatted, however there is a
standard set of conversion specifiers used for any object that
does not override them.
Conversion specifiers can themselves contain replacement fields.
For example, a field whose field width it itself a parameter
For example, a field whose field width is itself a parameter
could be specified via:
"{0:{1}}".format(a, b, c)
@ -184,12 +184,12 @@ Conversion Specifiers
the '{{' and '}}' syntax for escapes is only applied when used
*outside* of a format field. Within a format field, the brace
characters always have their normal meaning.
The syntax for conversion specifiers is open-ended, since except
than doing field replacements, the format() method does not
attempt to interpret them in any way; it merely passes all of the
characters between the first colon and the matching brace to
the various underlying formatter methods.
The syntax for conversion specifiers is open-ended, since a class
can override the standard conversion specifiers. In such cases,
the format() method merely passes all of the characters between
the first colon and the matching brace to the relevant underlying
formatting method.
Standard Conversion Specifiers
@ -206,7 +206,7 @@ Standard Conversion Specifiers
[[fill]align][sign][width][.precision][type]
The brackets ([]) indicate an optional field.
The brackets ([]) indicate an optional element.
Then the optional align flag can be one of the following:
@ -214,8 +214,8 @@ Standard Conversion Specifiers
space (This is the default.)
'>' - Forces the field to be right-aligned within the
available space.
'=' - Forces the padding to be placed between immediately
after the sign, if any. This is used for printing fields
'=' - Forces the padding to be placed after the sign (if any)
but before the digits. This is used for printing fields
in the form '+000000120'.
Note that unless a minimum field width is defined, the field
@ -229,7 +229,7 @@ Standard Conversion Specifiers
specifier). A zero fill character without an alignment flag
implies an alignment type of '='.
The 'sign' field can be one of the following:
The 'sign' element can be one of the following:
'+' - indicates that a sign should be used for both
positive as well as negative numbers
@ -244,9 +244,12 @@ Standard Conversion Specifiers
not specified, then the field width will be determined by the
content.
The 'precision' field is a decimal number indicating how many
digits should be displayed after the decimal point.
The 'precision' is a decimal number indicating how many digits
should be displayed after the decimal point in a floating point
conversion. In a string conversion the field indicates how many
characters will be used from the field content. The precision is
ignored for integer conversions.
Finally, the 'type' determines how the data should be presented.
If the type field is absent, an appropriate type will be assigned
based on the value to be formatted ('d' for integers and longs,