Jun-10-2019, 10:00 PM
Explained with code using your whatever function:
Just read the PEP.
In [6]: def whatever(my_cool_var=4 * 5 / 2): ...: print(my_cool_var) ...: In [7]: whatever() 10.0 In [8]: whatever(2) 2 In [9]: whatever(my_cool_var=2) 2 In [10]: def whatever(my_cool_var=4 * 5 / 2, /): ...: print(my_cool_var) ...: In [11]: whatever(my_cool_var=2) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-11-65f31df15028> in <module> ----> 1 whatever(my_cool_var=2) TypeError: whatever() got some positional-only arguments passed as keyword arguments: 'my_cool_var' In [12]: whatever(2) 2 In [13]: whatever() 10.0This is interesting for library developers who want to enforce the use of positional arguments, followed by keyword-arguments.
Just read the PEP.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!