How to ignore an output of a multi-output function in Python? -


this question has answer here:

suppose have function:

def f():   ...   ...   ...   return a,b,c 

and want b in output of function. assignment have use?

thanks.

you can unpack returned tuple dummy variables:

_, keep_this, _ = f() 

it doesn't have _, unused.

(don't use _ dummy name in interactive interpreter, there used holding last result.)

 

alternatively, index returned tuple:

keep_this = f()[1] 

Comments