Python Forum
/ token in function parameterlist
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
/ token in function parameterlist
#1
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                  ::=  identifier
on 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 t
This function acted the same way it would act if '/' wasn't in its parameter list. So what is the '/' about?
fracjackmac likes this post
Reply
#2
https://docs.python.org/3.8/whatsnew/3.8...parameters
fracjackmac likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Refresh token for Wyze SDK duckredbeard 0 1,115 May-16-2022, 04:33 AM
Last Post: duckredbeard
  Need to sign JWT token with JWK key stucoder 1 1,695 Feb-21-2022, 09:04 AM
Last Post: stucoder
  Python requests oauth2 access token herobpv 6 3,938 Sep-27-2021, 06:54 PM
Last Post: herobpv
  unexpected token < in json at position 0 Frodoxzibit 5 2,815 Jul-10-2021, 09:33 AM
Last Post: Larz60+
  Getting an "Unexpected Token" Error and don't know why... NotAHackusator 1 1,854 Nov-20-2019, 03:00 PM
Last Post: buran
  get and reuse the token value with huawei modem Reims 1 4,586 Oct-02-2019, 04:29 AM
Last Post: Reims
  Need help in adding xsrf token keerthiprashanth 1 2,046 Aug-08-2019, 02:35 PM
Last Post: keerthiprashanth
  Python - joining xmls together invalid token error jan86 0 2,217 Apr-26-2019, 08:52 AM
Last Post: jan86
  syntax error near unexpected token btom529 5 7,709 Apr-21-2019, 09:03 PM
Last Post: btom529
  tweepy:invalid or expired token weareux 2 6,469 Dec-03-2017, 07:27 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020