- 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).
This commit is contained in:
Mark Summerfield 2008-07-01 15:50:04 +00:00
parent 4c29b47d34
commit bbfd71d7ac
1 changed files with 33 additions and 26 deletions

View File

@ -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: