proper name for python * operator?

时光怂恿深爱的人放手 提交于 2019-11-25 23:18:26

问题


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


回答1:


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. I haven't heard any other particular name for it in Python.




回答2:


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




回答3:


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




回答4:


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




回答5:


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.




回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/2322355/proper-name-for-python-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!