Not found in the documentation

Paul Bryan pbryan at anode.ca
Mon Apr 26 19:43:46 EDT 2021


From https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy
:

> The string representations of the numeric classes, computed
> by__repr__() and __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.

Paul

On Mon, 2021-04-26 at 16:24 -0700, elas tica wrote:
> 
> Python documentation doesn't seem to mention anywhere what is the str
> value of an int: is it right?  the same for float, Fraction, complex,
> etc? Not worth to be documented? Perphaps str(42) returns "forty two"
> or "XLII" or "101010" ...



More information about the Python-list mailing list