288

What is the correct name for operator *, as in function(*args)? unpack, unzip, something else?

8
  • 17
    Javascript has the equivalent spread ... operator. Commented Dec 31, 2016 at 14:04
  • Just for reference, in the C++, it is called Dereference Operator (ref: cplusplus.com/doc/tutorial/pointers). Additionally, in Python, all variable to function (arguments) is pass by assignment. (ref: docs.python.org/3/faq/…) Commented Mar 23, 2021 at 4:17
  • 2
    @CloudCho The one in C++ stands for something entirely different. Commented Jun 6, 2021 at 15:37
  • @Sнаđошƒаӽ Would you describe the difference between Dereference Operator (C++) and Unpacking Operator (Python)? I thought both of them related to memory location rather than value in memory. Thanks. Commented Jun 9, 2021 at 18:02
  • @CloudCho Take a look at the official documentation. Commented Jun 10, 2021 at 3:47

9 Answers 9

254

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.

Sign up to request clarification or add additional context in comments.

7 Comments

Well in python it's also used to pack argument lists, so in that context should it be called unsplat? :)
@THC4k I propose splatsplat.
Unfortunately INTERCAL does not have * as an operator so we're lacking for an official source...
In JavaScript (es2015) it is known as the spread operator.
|
132

I call it "positional expansion", as opposed to ** which I call "keyword expansion".

Comments

55

The Python Tutorial simply calls it 'the *-operator'. It performs unpacking of arbitrary argument lists.

5 Comments

This is the most accurate answer and it's a shame it wasn't accepted!
@alfasin: The expression 'the *-operator' is ambiguous since * – depending on the context – can perform either argument expansion or multiplication which are two different operations.
@HelloGoodbye and it's really not difficult to understand which one it is from the context it's in.
Seems like the OP was asking how to pronounciate (which may or may not be a word itself - that's another rabbit hole) *. 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!".
If we go for simple let's call it star-operator. But ** could be dasterisk. Hm..
17

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

1 Comment

I also just say kwargs, although that doesn't really refer to the operator itself I suppose.
17

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.

2 Comments

but you can't yell gather or scatter like you can with SPLAT :D
@SamanthaBranham I like how gather and scatter can be easily and distinctly visualized. Of course splat visualizes great, too 😂💥
10

I believe it's most commonly called the "splat operator." Unpacking arguments is what it does.

Comments

3

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://stackoverflow.com/a/47875892/14305096

Comments

3

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!

Comments

-1

I call *args "star args" or "varargs" and **kwargs "keyword args".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.