Skip to content

Commit

Permalink
- No more 0L or similar.
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
Mark Summerfield committed Jul 1, 2008
1 parent 4c29b47 commit bbfd71d
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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, ``''``, ``()``, ``[]``.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit bbfd71d

Please sign in to comment.