splat

How does generator * / splat unpacking work?

How does generator * / splat unpacking work? Question: Let’s say I have some function f that will accept a variable number of arguments: def f(*args): for a in args: print(a) Below I call on this function three ways: Case 1: Passing in a generator expression without parenthesis: f(l for l in range(5)) >>> <generator …

Total answers: 1

Why does splatting create a tuple on the rhs but a list on the lhs?

Why does splatting create a tuple on the rhs but a list on the lhs? Question: Consider, for example, squares = *map((2).__rpow__, range(5)), squares # (0, 1, 4, 9, 16) *squares, = map((2).__rpow__, range(5)) squares # [0, 1, 4, 9, 16] So, all else being equal we get a list when splatting on the lhs …

Total answers: 7

proper name for python * operator?

proper name for python * operator? Question: What is the correct name for operator *, as in function(*args)? unpack, unzip, something else? Asked By: Anycorn || Source Answers: 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 …

Total answers: 9