## Positional-Only Parameters 

Looking at this in a bit more detail, it is possible to mark certain parameters as positional-only . If positional-only , the parameters’ order matters, and the parameters cannot be passed by keyword. Positional-only parameters are placed before a / (forward-slash). The / is used to logically separate the positional-only parameters from the rest of the parameters. If there is no / in the function definition, there are no positional-only parameters. 

Parameters following the / may be positional-or-keyword or keyword-only . 

## Keyword-Only Arguments 

To mark parameters as keyword-only , indicating the parameters must be passed by keyword argument, place an$_{*}$in the arguments list just before the first keyword-only parameter. 

## Function Examples 

Consider the following example function definitions paying close attention to the markers$_{/}$and$_{*}$ : 

>>>def standard_arg (arg): ... print(arg) ... >>>def pos_only_arg (arg,/): ... print(arg) ... >>>def kwd_only_arg (*, arg): ... print(arg) ... >>>def combined_example (pos_only, /, standard, *, kwd_only): ... print(pos_only, standard, kwd_only) 

The first function definition,$_{standard_arg}$ , the most familiar form, places no restrictions on the calling convention and arguments may be passed by position or keyword: 

>>> standard_arg( 2) 2 >>> standard_arg(arg =2) 2 

The second function$_{pos_only_arg}$ is restricted to only use positional parameters as there is a$_{/}$in the function definition: 

>>> pos_only_arg( 1) 1 >>> pos_only_arg(arg =1) Traceback (most recent call last): File "<stdin>" , line1, in <module> TypeError: pos_only_arg() got an unexpected keyword argument 'arg' 

The third function$_{kwd_only_args}$ only allows keyword arguments as indicated by a$_{*}$in the function definition: 

>>> kwd_only_arg( 3) Traceback (most recent call last): File "<stdin>" , line1, in <module> TypeError: kwd_only_arg() takes 0 positional arguments but 1 was given >>> kwd_only_arg(arg =3) 3 

