proper name for python * operator?

后端 未结 8 1999
不知归路
不知归路 2020-11-22 07:20

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

相关标签:
8条回答
  • 2020-11-22 07:33

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

    0 讨论(0)
  • 2020-11-22 07:36

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

    0 讨论(0)
  • 2020-11-22 07:37

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

    0 讨论(0)
  • 2020-11-22 07:40

    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

    0 讨论(0)
  • 2020-11-22 07:40

    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

    0 讨论(0)
  • 2020-11-22 07:41

    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.

    0 讨论(0)
提交回复
热议问题