Finding keyword arguments in the documentation
Peter Otten
__peter__ at web.de
Tue Sep 26 12:32:17 EDT 2017
Stefan Ram wrote:
> Here's a console transcript:
>
> |>>> from math import sin
> |>>> help( sin )
> |Help on built-in function sin in module math:
> |
> |sin(...)
> | sin(x)
> |
> | Return the sine of x (measured in radians).
> |
> |>>> sin( x = 2.0 )
> |Traceback (most recent call last):
> | File "<stdin>", line 1, in <module>
> |TypeError: sin() takes no keyword arguments
>
> How can I tell from the documentation of a callable
> entity whether a parameter name (like »x« above) can
> be used as a keyword in a keyword argument?
>
Newer Python versions will show
Help on built-in function sin in module math:
sin(x, /)
Return the sine of x (measured in radians).
where the arguments before the slash are positional-only:
https://www.python.org/dev/peps/pep-0457/#id14
More information about the Python-list
mailing list