Skip to content

Commit d6fd38e

Browse files
committed
Restrict Python's Numeric classes default external representations
1 parent 47be7d0 commit d6fd38e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Doc/reference/datamodel.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ Ellipsis
182182
related to mathematical numbers, but subject to the limitations of numerical
183183
representation in computers.
184184

185+
The string representations of the Numeric classes, computed by
186+
:meth:`__repr__` and :meth:`__str__`, have the following
187+
properties:
188+
189+
* They are valid numeric literals which, when passed to their
190+
class constructor, produce an object having the value of the
191+
original numeric.
192+
193+
* The representation is in base 10, when possible.
194+
195+
* Leading zeros, possibly excepting a single zero before a
196+
decimal point, are not shown.
197+
198+
* Trailing zeros, possibly excepting a single zero after a
199+
decimal point, are not shown.
200+
201+
* A sign is shown only when the number is negative.
202+
185203
Python distinguishes between integers, floating point numbers, and complex
186204
numbers:
187205

0 commit comments

Comments
 (0)