diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-04-22 18:15:25 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-04-22 18:15:25 (GMT) |
commit | 8100bd8431cae4b079ffc1f0c3e33ba019661994 (patch) | |
tree | 4e1d824f65678b76d2438e7a8edbc34689c4b4f3 /Doc | |
parent | ebafbb705cbc92e7917e2dea423c141ec2b276b4 (diff) | |
download | cpython-8100bd8431cae4b079ffc1f0c3e33ba019661994.zip cpython-8100bd8431cae4b079ffc1f0c3e33ba019661994.tar.gz cpython-8100bd8431cae4b079ffc1f0c3e33ba019661994.tar.bz2 |
Issue #5812: make Fraction('1e-6') valid. Backport of r71806.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/fractions.rst | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Doc/library/fractions.rst b/Doc/library/fractions.rst index 36df11c..5e9758e 100644 --- a/Doc/library/fractions.rst +++ b/Doc/library/fractions.rst @@ -27,20 +27,17 @@ another rational number, or from a string. *other_fraction* is an instance of :class:`numbers.Rational` and returns an :class:`Fraction` instance with the same value. The last version of the constructor expects a string or unicode - instance in one of two possible forms. The first form is:: + instance. The usual form for this instance is:: [sign] numerator ['/' denominator] where the optional ``sign`` may be either '+' or '-' and ``numerator`` and ``denominator`` (if present) are strings of - decimal digits. The second permitted form is that of a number - containing a decimal point:: - - [sign] integer '.' [fraction] | [sign] '.' fraction - - where ``integer`` and ``fraction`` are strings of digits. In - either form the input string may also have leading and/or trailing - whitespace. Here are some examples:: + decimal digits. In addition, any string that represents a finite + value and is accepted by the :class:`float` constructor is also + accepted by the :class:`Fraction` constructor. In either form the + input string may also have leading and/or trailing whitespace. + Here are some examples:: >>> from fractions import Fraction >>> Fraction(16, -10) @@ -58,6 +55,8 @@ another rational number, or from a string. Fraction(1414213, 1000000) >>> Fraction('-.125') Fraction(-1, 8) + >>> Fraction('7e-6') + Fraction(7, 1000000) The :class:`Fraction` class inherits from the abstract base class |