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

Skip to content

Commit bbfd71d

Browse files
author
Mark Summerfield
committed
- No more 0L or similar.
- Added cross-refs to fraction & decimal in numeric types. - Moved str.isdecimal() & str.isnumeric() into alphabetical order like all the other str methods; also massaged the text a bit to make it more consistent with the similar methods' texts. BTW The iterator.__iter__() docs seems to be out of step with functions.rst (where it now has an extra parameter).
1 parent 4c29b47 commit bbfd71d

1 file changed

Lines changed: 33 additions & 26 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ following values are considered false:
4646

4747
* ``False``
4848

49-
* zero of any numeric type, for example, ``0``, ``0L``, ``0.0``, ``0j``.
49+
* zero of any numeric type, for example, ``0``, ``0.0``, ``0j``.
5050

5151
* any empty sequence, for example, ``''``, ``()``, ``[]``.
5252

@@ -216,15 +216,17 @@ Numeric Types --- :class:`int`, :class:`float`, :class:`complex`
216216
object: complex number
217217
pair: C; language
218218

219-
There are three distinct numeric types: :dfn:`integers`, :dfn:`floating point
220-
numbers`, and :dfn:`complex numbers`. In addition, Booleans are a subtype of
221-
integers. Integers have unlimited precision. Floating point numbers are
222-
implemented using :ctype:`double` in C. All bets on their precision are off
223-
unless you happen to know the machine you are working with.
224-
225-
Complex numbers have a real and imaginary part, which are each implemented using
226-
:ctype:`double` in C. To extract these parts from a complex number *z*, use
227-
``z.real`` and ``z.imag``.
219+
There are three distinct numeric types: :dfn:`integers`, :dfn:`floating
220+
point numbers`, and :dfn:`complex numbers`. In addition, Booleans are a
221+
subtype of integers. Integers have unlimited precision. Floating point
222+
numbers are implemented using :ctype:`double` in C---all bets on their
223+
precision are off unless you happen to know the machine you are working
224+
with. Complex numbers have a real and imaginary part, which are each
225+
implemented using :ctype:`double` in C. To extract these parts from a
226+
complex number *z*, use ``z.real`` and ``z.imag``. (The standard library
227+
includes additional numeric types, :mod:`fractions` that hold rationals,
228+
and :mod:`decimal` that hold floating-point numbers with user-definable
229+
precision.)
228230

229231
.. index::
230232
pair: numeric; literals
@@ -356,6 +358,9 @@ All :class:`numbers.Real` types (:class:`int` and
356358
| ``math.ceil(x)`` | the least Integral >= *x* | |
357359
+--------------------+--------------------------------+--------+
358360

361+
For additional numeric operations see the :mod:`math` and :mod:`cmath`
362+
modules.
363+
359364
.. XXXJH exceptions: overflow (when? what operations?) zerodivision
360365
361366
@@ -756,6 +761,15 @@ functions based on regular expressions.
756761
one character, false otherwise.
757762

758763

764+
.. method:: str.isdecimal()
765+
766+
Return true if all characters in the string are decimal
767+
characters and there is at least one character, false
768+
otherwise. Decimal characters include digit characters, and all characters
769+
that that can be used to form decimal-radix numbers, e.g. U+0660,
770+
ARABIC-INDIC DIGIT ZERO.
771+
772+
759773
.. method:: str.isdigit()
760774

761775
Return true if all characters in the string are digits and there is at least one
@@ -774,6 +788,15 @@ functions based on regular expressions.
774788
least one cased character, false otherwise.
775789

776790

791+
.. method:: str.isnumeric()
792+
793+
Return true if all characters in the string are numeric
794+
characters, and there is at least one character, false
795+
otherwise. Numeric characters include digit characters, and all characters
796+
that have the Unicode numeric value property, e.g. U+2155,
797+
VULGAR FRACTION ONE FIFTH.
798+
799+
777800
.. method:: str.isprintable()
778801

779802
Return true if all characters in the string are printable or the string is
@@ -1017,22 +1040,6 @@ functions based on regular expressions.
10171040
returned if *width* is less than ``len(s)``.
10181041

10191042

1020-
.. method:: str.isnumeric()
1021-
1022-
Return ``True`` if there are only numeric characters in S, ``False``
1023-
otherwise. Numeric characters include digit characters, and all characters
1024-
that have the Unicode numeric value property, e.g. U+2155,
1025-
VULGAR FRACTION ONE FIFTH.
1026-
1027-
1028-
.. method:: str.isdecimal()
1029-
1030-
Return ``True`` if there are only decimal characters in S, ``False``
1031-
otherwise. Decimal characters include digit characters, and all characters
1032-
that that can be used to form decimal-radix numbers, e.g. U+0660,
1033-
ARABIC-INDIC DIGIT ZERO.
1034-
1035-
10361043

10371044
.. _old-string-formatting:
10381045

0 commit comments

Comments
 (0)