FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] gh-92417: `fractions`, `decimal`: Improve docs for alternative constructor methods (GH-92421) by miss-islington · Pull Request #92971 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions Doc/library/decimal.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,10 @@ Decimal objects
>>> Decimal(321).exp()
Decimal('2.561702493119680037517373933E+139')

.. method:: from_float(f)
.. classmethod:: from_float(f)

Classmethod that converts a float to a decimal number, exactly.
Alternative constructor that only accepts instances of :class:`float` or
:class:`int`.

Note `Decimal.from_float(0.1)` is not the same as `Decimal('0.1')`.
Since 0.1 is not exactly representable in binary floating point, the
Expand Down
12 changes: 6 additions & 6 deletions Doc/library/fractions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ another rational number, or from a string.

.. versionadded:: 3.8

.. method:: from_float(flt)
.. classmethod:: from_float(flt)

This class method constructs a :class:`Fraction` representing the exact
value of *flt*, which must be a :class:`float`. Beware that
Alternative constructor which only accepts instances of
:class:`float` or :class:`numbers.Integral`. Beware that
``Fraction.from_float(0.3)`` is not the same value as ``Fraction(3, 10)``.

.. note::
Expand All @@ -117,10 +117,10 @@ another rational number, or from a string.
:class:`Fraction` instance directly from a :class:`float`.


.. method:: from_decimal(dec)
.. classmethod:: from_decimal(dec)

This class method constructs a :class:`Fraction` representing the exact
value of *dec*, which must be a :class:`decimal.Decimal` instance.
Alternative constructor which only accepts instances of
:class:`decimal.Decimal` or :class:`numbers.Integral`.

.. note::

Expand Down

Back | FazBrowse Home | New Git URL