EDIT: This was closed as a duplicate of this post, however as I noted in the OP the usage here clearly not related to list/dictionary unpacking, this is a distinct question.
While reading the docs for the subprocess
module I noticed that a number of methods take an *
argument. For example, subprocess.run:
subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None,
capture_output=False, shell=False, cwd=None, timeout=None,
check=False, encoding=None, errors=None, text=None, env=None,
universal_newlines=None, **other_popen_kwargs)
I initially interpreted that to mean the preceding positional argument (args
in this case) could be repeated any number of times before key-word arguments, but I don't think that is correct. For example, the subprocess.Popen
constructor also has an argument referred to only as *
, but in that case it follows a keyword argument (pass_fds
).
subprocess.Popen(args, bufsize=- 1, executable=None, stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None,
universal_newlines=None, startupinfo=None, creationflags=0,
restore_signals=True, start_new_session=False, pass_fds=(), *, group=None,
extra_groups=None, user=None, umask=- 1, encoding=None, errors=None,
text=None, pipesize=- 1)
Attempting to search for this just returns results about using *args
and **kwargs
, and looking at the source code has not elucidated anything to me.