0

I have a function (func1) that returns a 4-tuple of mixed strings and integers. I want to immediately pass these 4 values into a second function (func2). This is how I am doing it now:

var1, var2, var3, var4 = func1(input1)
func2(var1, var2, var3, var4)

Functions don't unpack tuples when given as input, so this code is broken:

func2(func1(input1))

Is there a pythonic way to implement this code in the style of the second code block so func2 will unpack the values or some equivalent?

Angus
  • 349
  • 3
  • 10

1 Answers1

4

Use the * operator:

func2(*func1(input1))
Community
  • 1
  • 1
shx2
  • 61,779
  • 13
  • 130
  • 153