reference document PEP 457-- Syntax For Positional-Only Parameters
python.org/dev/peps/pep-0457/" rel=" nofollow noreferrer "> https://www.python.org/dev/pe.
There are two parameters for
python
- position parameter (positional argument)
- keyword parameter (keyword argument)
such as def foo (a, bread1): pass
, where a is the position parameter and b is the keyword parameter.
two other common definitions, such as
def sum(*args):
pass
def option(**kwargs):
pass
where args represents a parameter array (list type), and kwargs represents a parameter dictionary (dict type).
the corresponding calling method, such as
sum(1, 2)
option(a=1, b=2)
finally, def readlines (hints=-1, /): pass
, where / does not represent any parameters, it indicates that the preceding parameters are positional parameters, and there are no keyword parameters. So readlines (1)
can, but readlines (hints=1)
cannot.
currently (August 29th, 2018), this syntax is only defined in python C, and python has not yet been implemented.
"python.org/dev/peps/pep-0457/" rel= "nofollow noreferrer" > https://www.python.org/dev/pe. "
is going to climb the wall.
in fact, I don't quite understand, positional argument. It probably means that it is sorted according to the rules, and you can't arrange it at will with arg=1 or (a ~) or (~) ~
that forward slash, that is, the forward slash def func (a _ mlmple _ rem _ b) indicates that the preceding parameter is positional only argmument.
however, I don't understand how this kind of syntax can be run, because slashes generally cannot be used as parameters. I hope someone can help me with the answer.
maybe this is just a hint on the document, right?
by the way, there is a difference between sys.stdin.readlines (1) and sys.stdin.readlines (- 1) on idle. The former ends the input state after I type characters and wraps the line directly, while the latter I need ctrl+D to finish.