开发者

Import a bunch of parameters as a dictionary?

I want to put all the parameters of my co开发者_开发知识库de in a parameter file (parms.py), so that everything I may need to tweak later will be at the same place. What would be the best way to import just the parameters I want, to save some work?

I was thinking of grouping my parameters in dictionaries; is that the Pythonic way? I think the code will look funny, using the parameters like: parms_dict('parameter1')

from parms.py import * # import lots of useless parameters (should I worry about that?)

or

from parms.py import parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7 # That way can get very long and ugly (should I worry about that?)

Any better suggestions/comments?


Just import the module and access the parameters you want using their fully-qualiifed names:

import parms

parms.foo
parms.bar
parms.baz
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜