python:从字典调用构造函数?
我不太确定这里的术语,所以请耐心等待......
假设我有一个像这样的构造函数调用:
machineSpecificEnvironment = Environment(
TI_C28_ROOT = 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000',
JSDB = 'c:/bin/jsdb/jsdb.exe',
PYTHON_PATH = 'c:/appl/python/2.6.4',
)
除了我想用提供给我的字典上的操作替换它:
keys = {'TI_C28_ROOT': 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000',
'JSDB': 'c:/bin/jsdb/jsdb.exe',
'PYTHON_PATH': 'c:/appl/python/2.6.4'}
machineSpecificEnvironment = Environment(
... what do I put here? it needs to be a function of "keys" ...
)
我该怎么办这?
I'm not quite sure of the terminology here so please bear with me....
Let's say I have a constructor call like this:
machineSpecificEnvironment = Environment(
TI_C28_ROOT = 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000',
JSDB = 'c:/bin/jsdb/jsdb.exe',
PYTHON_PATH = 'c:/appl/python/2.6.4',
)
except I would like to replace that by an operation on a dictionary provided to me:
keys = {'TI_C28_ROOT': 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000',
'JSDB': 'c:/bin/jsdb/jsdb.exe',
'PYTHON_PATH': 'c:/appl/python/2.6.4'}
machineSpecificEnvironment = Environment(
... what do I put here? it needs to be a function of "keys" ...
)
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过 ** 符号将字典应用为参数列表
You can apply a dict as an argument list by the ** notation