diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-01-12 01:56:00 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-01-12 01:56:00 (GMT) |
commit | 59bc20bb273055e2cd48a467524d21340c1771cc (patch) | |
tree | 5c56af6a822827d080e136a8f9ee819ee589d4af /Doc | |
parent | bed4dd459ddebec5bf43ef8c658ed4a194b518cb (diff) | |
download | cpython-59bc20bb273055e2cd48a467524d21340c1771cc.zip cpython-59bc20bb273055e2cd48a467524d21340c1771cc.tar.gz cpython-59bc20bb273055e2cd48a467524d21340c1771cc.tar.bz2 |
Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/decimal.rst | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index eda09e4..7b85806 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -281,9 +281,10 @@ Decimal objects Construct a new :class:`Decimal` object based from *value*. - *value* can be an integer, string, tuple, or another :class:`Decimal` object. If - no *value* is given, returns ``Decimal("0")``. If *value* is a string, it - should conform to the decimal numeric string syntax:: + *value* can be an integer, string, tuple, or another :class:`Decimal` + object. If no *value* is given, returns ``Decimal("0")``. If *value* is a + string, it should conform to the decimal numeric string syntax after leading + and trailing whitespace characters are removed:: sign ::= '+' | '-' digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' @@ -313,6 +314,10 @@ Decimal objects Once constructed, :class:`Decimal` objects are immutable. + .. versionchanged:: 2.6 + leading and trailing whitespace characters are permitted when + creating a Decimal instance from a string. + Decimal floating point objects share many properties with the other built-in numeric types such as :class:`float` and :class:`int`. All of the usual math operations and special methods apply. Likewise, decimal objects can be copied, @@ -973,6 +978,9 @@ method. For example, ``C.exp(x)`` is equivalent to >>> Decimal("3.4445") + Decimal(0) + Decimal("1.0023") Decimal("4.44") + This method implements the to-number operation of the IBM + specification. If the argument is a string, no leading or trailing + whitespace is permitted. .. method:: Context.Etiny() |