我有以下内容:
class Foo:
def __init__(self, **kwargs):
print kwargs
settings = {foo:"bar"}
f = Foo(settings)
这会产生一个错误:
Traceback (most recent call last):
File "example.py", line 12, in <module>
settings = {foo:"bar"}
NameError: name 'foo' is not defined
如何正确地将键/值 args 的字典传递给 kwargs?