Apr-12-2020, 06:17 PM
So I'm learning python by just reading documentation after I decided that none of the books and courses out there are good enough. Here's the question in the funcdef documentation we have
I wrote the function bellow:
funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")"
["->" expression] ":" suite
decorators ::= decorator+
decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
dotted_name ::= identifier ("." identifier)*
parameter_list ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
| parameter_list_no_posonly
parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
| parameter_list_starargs
parameter_list_starargs ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
| "**" parameter [","]
parameter ::= identifier [":" expression]
defparameter ::= parameter ["=" expression]
funcname ::= identifieron the parameter_list line, you see "/" but there is no explanation of its effect anywhere...I wrote the function bellow:
def f(t: int = 2, /): return tThis function acted the same way it would act if '/' wasn't in its parameter list. So what is the '/' about?
