Skip to content

Commit

Permalink
Restrict Python's Numeric classes default external representations
Browse files Browse the repository at this point in the history
  • Loading branch information
kpinc committed Jan 22, 2020
1 parent 47be7d0 commit d6fd38e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ Ellipsis
related to mathematical numbers, but subject to the limitations of numerical
representation in computers.

The string representations of the Numeric classes, computed by
:meth:`__repr__` and :meth:`__str__`, have the following
properties:

* They are valid numeric literals which, when passed to their
class constructor, produce an object having the value of the
original numeric.

* The representation is in base 10, when possible.

* Leading zeros, possibly excepting a single zero before a
decimal point, are not shown.

* Trailing zeros, possibly excepting a single zero after a
decimal point, are not shown.

* A sign is shown only when the number is negative.

Python distinguishes between integers, floating point numbers, and complex
numbers:

Expand Down

0 comments on commit d6fd38e

Please sign in to comment.