I have noticed a few functions' signatures with a /
parameter. An example of this can be found in collections.Counter.__init__()
:
def __init__(self, iterable=None, /, **kwds):
'''Create a new, empty Counter object. And if given, count elements
from an input iterable. Or, initialize the count from another mapping
of elements to their counts.
>>> c = Counter() # a new, empty counter
>>> c = Counter('gallahad') # a new counter from an iterable
>>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
>>> c = Counter(a=4, b=2) # a new counter from keyword args
'''
super().__init__()
self.update(iterable, **kwds)
I have not been able to find what it is used for and when I try to replicate it locally I get a SyntaxError
.
Any information on what it is and why it is used would be appreciated.