Python named keyword by variable -


i'm new python , i'm trying figure out if can pass named keywords string without calling them explicitly. here example:

def test(height, weight):     print("h=" + str(height))     print("w=" + str(weight))  test(weight=1, height=2) # output  = "weight" b = "height"  test(a=1, b=2) # same output 

is possibile? thanks!

use dict.

kwargs = {a: 1, b: 2} test(**kwargs) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -