Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b27c2d

Browse files
committed
Issues #28916, #26483: Merge stdtypes.rst from 3.6
2 parents 274c01f + 0a7b859 commit 2b27c2d

2 files changed

Lines changed: 20 additions & 38 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,18 +1644,20 @@ expression support in the :mod:`re` module).
16441644

16451645
Return true if all characters in the string are decimal
16461646
characters and there is at least one character, false
1647-
otherwise. Decimal characters are those from general category "Nd". This category
1648-
includes digit characters, and all characters
1649-
that can be used to form decimal-radix numbers, e.g. U+0660,
1650-
ARABIC-INDIC DIGIT ZERO.
1647+
otherwise. Decimal characters are those that can be used to form
1648+
numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT
1649+
ZERO. Formally a decimal character is a character in the Unicode
1650+
General Category "Nd".
16511651

16521652

16531653
.. method:: str.isdigit()
16541654

16551655
Return true if all characters in the string are digits and there is at least one
16561656
character, false otherwise. Digits include decimal characters and digits that need
1657-
special handling, such as the compatibility superscript digits. Formally, a digit
1658-
is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal.
1657+
special handling, such as the compatibility superscript digits.
1658+
This covers digits which cannot be used to form numbers in base 10,
1659+
like the Kharosthi numbers. Formally, a digit is a character that has the
1660+
property value Numeric_Type=Digit or Numeric_Type=Decimal.
16591661

16601662

16611663
.. method:: str.isidentifier()
@@ -2199,15 +2201,12 @@ The conversion types are:
21992201
Notes:
22002202

22012203
(1)
2202-
The alternate form causes a leading zero (``'0'``) to be inserted between
2203-
left-hand padding and the formatting of the number if the leading character
2204-
of the result is not already a zero.
2204+
The alternate form causes a leading octal specifier (``'0o'``) to be
2205+
inserted before the first digit.
22052206

22062207
(2)
22072208
The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
2208-
the ``'x'`` or ``'X'`` format was used) to be inserted between left-hand padding
2209-
and the formatting of the number if the leading character of the result is not
2210-
already a zero.
2209+
the ``'x'`` or ``'X'`` format was used) to be inserted before the first digit.
22112210

22122211
(3)
22132212
The alternate form causes the result to always contain a decimal point, even if
@@ -3303,15 +3302,12 @@ The conversion types are:
33033302
Notes:
33043303

33053304
(1)
3306-
The alternate form causes a leading zero (``'0'``) to be inserted between
3307-
left-hand padding and the formatting of the number if the leading character
3308-
of the result is not already a zero.
3305+
The alternate form causes a leading octal specifier (``'0o'``) to be
3306+
inserted before the first digit.
33093307

33103308
(2)
33113309
The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
3312-
the ``'x'`` or ``'X'`` format was used) to be inserted between left-hand padding
3313-
and the formatting of the number if the leading character of the result is not
3314-
already a zero.
3310+
the ``'x'`` or ``'X'`` format was used) to be inserted before the first digit.
33153311

33163312
(3)
33173313
The alternate form causes the result to always contain a decimal point, even if

Lib/test/test_format.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,42 +200,28 @@ def test_common_format(self):
200200
testcommon("%#+37.34o", big, "+0o0012345670123456701234567012345670")
201201
# next one gets one leading zero from precision
202202
testcommon("%.33o", big, "012345670123456701234567012345670")
203-
# base marker shouldn't change that, since "0" is redundant
203+
# base marker added in spite of leading zero (different to Python 2)
204204
testcommon("%#.33o", big, "0o012345670123456701234567012345670")
205-
# but reduce precision, and base marker should add a zero
205+
# reduce precision, and base marker is always added
206206
testcommon("%#.32o", big, "0o12345670123456701234567012345670")
207-
# one leading zero from precision, and another from "0" flag & width
208-
testcommon("%034.33o", big, "0012345670123456701234567012345670")
209-
# base marker shouldn't change that
210-
testcommon("%0#34.33o", big, "0o012345670123456701234567012345670")
207+
# one leading zero from precision, plus two from "0" flag & width
208+
testcommon("%035.33o", big, "00012345670123456701234567012345670")
209+
# base marker shouldn't change the size
210+
testcommon("%0#35.33o", big, "0o012345670123456701234567012345670")
211211
# Some small ints, in both Python int and flavors).
212212
testcommon("%d", 42, "42")
213213
testcommon("%d", -42, "-42")
214-
testcommon("%d", 42, "42")
215-
testcommon("%d", -42, "-42")
216214
testcommon("%d", 42.0, "42")
217215
testcommon("%#x", 1, "0x1")
218-
testcommon("%#x", 1, "0x1")
219-
testcommon("%#X", 1, "0X1")
220216
testcommon("%#X", 1, "0X1")
221217
testcommon("%#o", 1, "0o1")
222-
testcommon("%#o", 1, "0o1")
223-
testcommon("%#o", 0, "0o0")
224218
testcommon("%#o", 0, "0o0")
225219
testcommon("%o", 0, "0")
226-
testcommon("%o", 0, "0")
227220
testcommon("%d", 0, "0")
228-
testcommon("%d", 0, "0")
229-
testcommon("%#x", 0, "0x0")
230221
testcommon("%#x", 0, "0x0")
231222
testcommon("%#X", 0, "0X0")
232-
testcommon("%#X", 0, "0X0")
233223
testcommon("%x", 0x42, "42")
234224
testcommon("%x", -0x42, "-42")
235-
testcommon("%x", 0x42, "42")
236-
testcommon("%x", -0x42, "-42")
237-
testcommon("%o", 0o42, "42")
238-
testcommon("%o", -0o42, "-42")
239225
testcommon("%o", 0o42, "42")
240226
testcommon("%o", -0o42, "-42")
241227
# alternate float formatting

0 commit comments

Comments
 (0)