argument-unpacking

Passing an array/list into a Python function

Passing an array/list into a Python function Question: I’ve been looking at passing arrays, or lists, as Python tends to call them, into a function. I read something about using *args, such as: def someFunc(*args) for x in args print x But not sure if this is right/wrong. Nothing seems to work as I want. …

Total answers: 5

What does the star and doublestar operator mean in a function call?

What do ** (double star/asterisk) and * (star/asterisk) mean in a function call? Question: In code like zip(*x) or f(**k), what do the * and ** respectively mean? How does Python implement that behaviour, and what are the performance implications? See also: Expanding tuples into arguments. Please use that one to close questions where OP …

Total answers: 4

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

What does ** (double star/asterisk) and * (star/asterisk) do for parameters? Question: What do *args and **kwargs mean in these function definitions? def foo(x, y, *args): pass def bar(x, y, **kwargs): pass See What do ** (double star/asterisk) and * (star/asterisk) mean in a function call? for the complementary question about arguments. Asked By: Todd …

Total answers: 27