mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
fix markup
This commit is contained in:
parent
e753abdec7
commit
aa0a0b9007
1 changed files with 9 additions and 10 deletions
|
@ -88,22 +88,21 @@ Other Language Changes
|
||||||
|
|
||||||
Some smaller changes made to the core Python language are:
|
Some smaller changes made to the core Python language are:
|
||||||
|
|
||||||
* The string :method:`format` method now supports automatic numbering
|
* :meth:`str.format` method now supports automatic numbering of the replacement
|
||||||
of the replacement fields. This makes using :meth:`format`
|
fields. This makes using :meth:`str.format` more closely resemble using
|
||||||
more closely resemble using ``%s`` formatting::
|
``%s`` formatting::
|
||||||
|
|
||||||
>>> '{}:{}:{}'.format(2009, 04, 'Sunday')
|
>>> '{}:{}:{}'.format(2009, 04, 'Sunday')
|
||||||
'2009:4:Sunday'
|
'2009:4:Sunday'
|
||||||
>>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
|
>>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
|
||||||
'2009:4:Sunday'
|
'2009:4:Sunday'
|
||||||
|
|
||||||
The auto-numbering takes the fields from left to right, so the first
|
The auto-numbering takes the fields from left to right, so the first ``{...}``
|
||||||
``{...}`` specifier will use the first argument to :meth:`format`,
|
specifier will use the first argument to :meth:`str.format`, the next
|
||||||
the next specifier will use the next argument, and so on. You can't
|
specifier will use the next argument, and so on. You can't mix auto-numbering
|
||||||
mix auto-numbering and explicit numbering -- either number all of
|
and explicit numbering -- either number all of your specifier fields or none
|
||||||
your specifier fields or none of them -- but you can mix
|
of them -- but you can mix auto-numbering and named fields, as in the second
|
||||||
auto-numbering and named fields, as in the second example above.
|
example above. (Contributed by XXX; :issue`5237`.)
|
||||||
(Contributed by XXX; :issue`5237`.)
|
|
||||||
|
|
||||||
* The :func:`int` and :func:`long` types gained a ``bit_length``
|
* The :func:`int` and :func:`long` types gained a ``bit_length``
|
||||||
method that returns the number of bits necessary to represent
|
method that returns the number of bits necessary to represent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue