Skip to content
Advertisement

Python unpack different elements in tuple into *args

JavaScript

I want to convert it into something like this:

JavaScript

so that I can pass it into another function

JavaScript

Advertisement

Answer

You could use iterable unpacking to do this.

You can unpack an iterable by prefixing it with * when passing it into a function.

foo(int(var[0]), *var[1]) would give you what you want.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement