Вопрос

From an external file I generate the following dictionary:

mydict = { 'foo' : 123, 'bar' : 456 }

Given a function that takes a **kwargs argument, how can generate the keyword-args from that dictionary?

Это было полезно?

Решение

def foo(**kwargs):
    pass

foo(**{ 'foo' : 123, 'bar' : 456 })
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top