optional int- and float arguments

Chris Angelico rosuav at gmail.com
Tue Oct 3 13:35:33 EDT 2017


On Wed, Oct 4, 2017 at 3:18 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>   »int« and »float« seem to behave quite similar:
>
> |>>> int( x = 8 )
> |8
> |>>> float( x = 8.0 )
> |8.0
> |>>> int()
> |0
> |>>> float()
> |0.0
>
>   . Yet the ways their parameters are being documented in
>   "The Python Library Reference, Release 3.6.0" seem to differ:
>
> |class float([x])
> |class int(x=0)
>

Huh. I just checked help() in Python 3.7, and it's the other way around.

 |  float(x=0, /)
 |  int([x]) -> integer

>   Would there be any error in describing »float« using
>
> |class float(x=0.0)
>
>   ?

I don't think so. This is a strange inconsistency in the docs, given
that they behave the same way. Would be worth opening a tracker issue,
mentioning all four things you found.

ChrisA



More information about the Python-list mailing list