Passing a dictionary to a function in python as keyword parameters -


i'd call function in python using dictionary.

here code:

d = dict(param='test')  def f(param):     print param  f(d) 

this prints {'param': 'test'} i'd print test.

i'd work more parameters:

d = dict(p1=1, p2=2) def f2(p1,p2):     print p1, p2 f2(d) 

is possible?

figured out myself in end. simple, missing ** operator unpack dictionary

so example becomes:

d = dict(p1=1, p2=2) def f2(p1,p2):     print p1, p2 f2(**d) 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -