/ token in function parameterlist - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: / token in function parameterlist (/thread-25824.html) |
/ token in function parameterlist - tpourjalali - Apr-12-2020 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 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? RE: / token in function parameterlist - deanhystad - Apr-12-2020 https://docs.python.org/3.8/whatsnew/3.8.html#positional-only-parameters |