Not found in the documentation

Terry Reedy tjreedy at udel.edu
Tue Apr 27 02:54:48 EDT 2021


On 4/26/2021 7:24 PM, 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" ...

Python has this thing called interactive mode that makes it possible to 
discover answers even faster than looking in the docs (which can get out 
of date when things change, as they have for floats).

str(12345)
'12345'
repr(12345)
'12345'
str(1+1*j)
Traceback (most recent call last):
   File "<pyshell#3>", line 1, in <module>
     if True:
NameError: name 'j' is not defined
str(1+1j)
'(1+1j)'
repr(1+1j)
'(1+1j)'
str(.9999999999999999999999999999999)
'1.0'
str(0xff34)
'65332'



-- 
Terry Jan Reedy



More information about the Python-list mailing list