What is the correct name for operator *
, as in function(*args)
? unpack, unzip, something else?
In Ruby and Perl 6 this has been called "splat", and I think most people from those communities will figure out what you mean if you call it that.
The Python tutorial uses the phrase "unpacking argument lists", which is long and descriptive.
It is also referred to as iterable unpacking, or in the case of **
,
dictionary unpacking.
splatsplat
. –
Meed *
as an operator so we're lacking for an official source... –
Tolle I call it "positional expansion", as opposed to **
which I call "keyword expansion".
The Python Tutorial simply calls it 'the *
-operator'. It performs unpacking of arbitrary argument lists.
*
-operator' is ambiguous since *
– depending on the context – can perform either argument expansion or multiplication which are two different operations. –
Skeptic *
. By saying it's the *-operator
is simply throwing the question back as an answer. OP probably wanted to know how to say it out loud (or in his head) when he encounters it. This is all new to me, and I'll be going with "splat!". –
Diversiform I say "star-args" and Python people seem to know what i mean.
**
is trickier - I think just "qargs" since it is usually used as **kw
or **kwargs
kwargs
, although that doesn't really refer to the operator itself I suppose. –
Churn One can also call *
a gather parameter (when used in function arguments definition) or a scatter operator (when used at function invocation).
As seen here: Think Python/Tuples/Variable-length argument tuples.
I believe it's most commonly called the "splat operator." Unpacking arguments is what it does.
For a colloquial name there is "splatting".
For arguments (list type) you use single *
and for keyword arguments (dictionary type) you use double **
.
Both *
and **
is sometimes referred to as "splatting".
See for reference of this name being used: https://mcmap.net/q/66944/-is-there-an-object-spread-syntax-in-python-2-7x-like-in-javascript
The technical term for this is a Variadic function. So in a sense, that's the correct term without regard to programming language.
That said, in different languages the term does have legitimate names. As others have mentioned, it is called "splat" in ruby, julia, and several other languages and is noted by that name in official documentation. In javascript it is called the "spread" syntax. It has many other names in many other languages, as mentioned in other answers. Whatever you call it, it's quite useful!
I call *args "star args" or "varargs" and **kwargs "keyword args".
© 2022 - 2024 — McMap. All rights reserved.
...
operator. – Goldeneyeprint(*Dictionary)
, it shows only Key in Dictionary. Would you give additional information? Thanks. – Eskew*
is also...
, used in template parameter packs. – Yellowknife