标签归档:splat

python *运算符的专有名称?

问题:python *运算符的专有名称?

什么是运营商的正确名称*,如function(*args)?打开包装,解压缩,还有其他东西吗?

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


回答 0

在Ruby和Perl 6中,这被称为“ splat”,我认为那些社区的大多数人都会明白您的意思。

Python的教程使用短语“拆包参数列表”,这是长和描述。我在Python中还没有听说过其他特殊名称。

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.


回答 1

我称之为“位置扩展”,与之相反**,我称之为“关键字扩展”。

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


回答 2

Python的教程简单地说,这是的*-运算符“。它执行任意参数列表的解压缩。

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


回答 3

我说“ star-args”,Python的人似乎知道我的意思。

**比较棘手-我认为只是“ qargs”,因为它通常用作**kw**kwargs

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


回答 4

你也可以拨打*一个聚集参数(在函数参数定义中使用时)或分散操作时(在函数调用中使用)。

如此处所示:考虑Python / Tuples / Variable-length参数元组

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.


回答 5

我相信它最常被称为“ splat运算符”。解压缩参数是它的作用。

I believe it’s most commonly called the “splat operator.” Unpacking arguments is what it does.


回答 6

我将* args称为“ star args”或“ varargs”,并将** kwargs称为“ keyword args”。

I call *args “star args” or “varargs” and **kwargs “keyword args”.