Reputation: 3374
According to this tutorial the under the section "Special parameters" (https://docs.python.org/3/tutorial/controlflow.html#defining-functions) the following unusual function definition should be valid:
def test_special(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):
print("in test_special")
print("pos1: " + pos1)
print("pos2: " + pos2)
print("pos_or_kwd: " + pos_or_kwd)
print("kwd1: " + kwd1)
print("kwd2: " + kwd2)
However I get the error:
$ python TestArgs.py
File "TestArgs.py", line 11
def test_special(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):
^
SyntaxError: invalid syntax
I'm using Python version 3.7.5.
Upvotes: 0
Views: 90
Reputation: 110263
The /
in the list of parameters in a function definition is a new syntax allwoed from Python 3.8.0 and forward.
It is a SyntaxError in Python 3.7
Upvotes: 3