diff options
author | Mark Summerfield <list@qtrac.plus.com> | 2008-07-01 15:50:04 (GMT) |
---|---|---|
committer | Mark Summerfield <list@qtrac.plus.com> | 2008-07-01 15:50:04 (GMT) |
commit | bbfd71d7ac02bc2053a0ba494a3f055fbec8deee (patch) | |
tree | d2c01b006a11d4a223e23bba3cd06d9bdfceea36 /Doc/library | |
parent | 4c29b47d3496e86b3cd6c4735231838f8ca4e942 (diff) | |
download | cpython-bbfd71d7ac02bc2053a0ba494a3f055fbec8deee.zip cpython-bbfd71d7ac02bc2053a0ba494a3f055fbec8deee.tar.gz cpython-bbfd71d7ac02bc2053a0ba494a3f055fbec8deee.tar.bz2 |
- 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).
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/stdtypes.rst | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 4cb14e7..4db5653 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -46,7 +46,7 @@ following values are considered false: * ``False`` -* zero of any numeric type, for example, ``0``, ``0L``, ``0.0``, ``0j``. +* zero of any numeric type, for example, ``0``, ``0.0``, ``0j``. * any empty sequence, for example, ``''``, ``()``, ``[]``. @@ -216,15 +216,17 @@ Numeric Types --- :class:`int`, :class:`float`, :class:`complex` object: complex number pair: C; language -There are three distinct numeric types: :dfn:`integers`, :dfn:`floating point -numbers`, and :dfn:`complex numbers`. In addition, Booleans are a subtype of -integers. Integers have unlimited precision. Floating point numbers are -implemented using :ctype:`double` in C. All bets on their precision are off -unless you happen to know the machine you are working with. - -Complex numbers have a real and imaginary part, which are each implemented using -:ctype:`double` in C. To extract these parts from a complex number *z*, use -``z.real`` and ``z.imag``. +There are three distinct numeric types: :dfn:`integers`, :dfn:`floating +point numbers`, and :dfn:`complex numbers`. In addition, Booleans are a +subtype of integers. Integers have unlimited precision. Floating point +numbers are implemented using :ctype:`double` in C---all bets on their +precision are off unless you happen to know the machine you are working +with. Complex numbers have a real and imaginary part, which are each +implemented using :ctype:`double` in C. To extract these parts from a +complex number *z*, use ``z.real`` and ``z.imag``. (The standard library +includes additional numeric types, :mod:`fractions` that hold rationals, +and :mod:`decimal` that hold floating-point numbers with user-definable +precision.) .. index:: pair: numeric; literals @@ -356,6 +358,9 @@ All :class:`numbers.Real` types (:class:`int` and | ``math.ceil(x)`` | the least Integral >= *x* | | +--------------------+--------------------------------+--------+ +For additional numeric operations see the :mod:`math` and :mod:`cmath` +modules. + .. XXXJH exceptions: overflow (when? what operations?) zerodivision @@ -756,6 +761,15 @@ functions based on regular expressions. one character, false otherwise. +.. method:: str.isdecimal() + + Return true if all characters in the string are decimal + characters and there is at least one character, false + otherwise. Decimal characters include digit characters, and all characters + that that can be used to form decimal-radix numbers, e.g. U+0660, + ARABIC-INDIC DIGIT ZERO. + + .. method:: str.isdigit() 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. least one cased character, false otherwise. +.. method:: str.isnumeric() + + Return true if all characters in the string are numeric + characters, and there is at least one character, false + otherwise. Numeric characters include digit characters, and all characters + that have the Unicode numeric value property, e.g. U+2155, + VULGAR FRACTION ONE FIFTH. + + .. method:: str.isprintable() Return true if all characters in the string are printable or the string is @@ -1017,22 +1040,6 @@ functions based on regular expressions. returned if *width* is less than ``len(s)``. -.. method:: str.isnumeric() - - Return ``True`` if there are only numeric characters in S, ``False`` - otherwise. Numeric characters include digit characters, and all characters - that have the Unicode numeric value property, e.g. U+2155, - VULGAR FRACTION ONE FIFTH. - - -.. method:: str.isdecimal() - - Return ``True`` if there are only decimal characters in S, ``False`` - otherwise. Decimal characters include digit characters, and all characters - that that can be used to form decimal-radix numbers, e.g. U+0660, - ARABIC-INDIC DIGIT ZERO. - - .. _old-string-formatting: |