Reading the documentation
MRAB
python at mrabarnett.plus.com
Thu Aug 24 16:08:16 EDT 2017
On 2017年08月24日 20:24, Stefan Ram wrote:
> This is a transcript:
>>>>> from math import floor
>>>> floor( "2.3" )
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: must be real number, not str
>>>> help(floor)
> Help on built-in function floor in module math:
>> floor(...)
> floor(x)
>> Return the floor of x as an Integral.
> This is the largest integer <= x.
>> Is the output of »help(floor)« supposed to be a kind of
> normative documentation, i.e., /the/ authoritative
> documentation of »floor«?
>> Is there any hint in the documentation about the type
> expected of arguments in a call?
>> Is a parameter name »x« (as used above) described
> somewhere to express the requirement of a real number?
>> It seems, »real« means »int or float«. Is this meaning
> of »real« documented somewhere?
>> Thanks in advance!
>As the module is called "math", it's not surprising that "floor" expects
a number and rejects a string.
There's also a "cmath" module, which handles complex numbers.
"real" can be int, float or Decimal, but not complex.
More information about the Python-list
mailing list