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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -