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

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -