Reputation: 461
When I follow this oslo config tutorial:
in the 2:00
, there:
from oslo_config import cfg
from pprint import pprint
res = [{k:v} for k, v in cfg.CONF.iteritems()]
pprint(res)
In the tutorial there print []
,
but in my PyCharm, there is a
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/oslo_config/cfg.py", line 2193, in __getattr__
return self._get(name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/oslo_config/cfg.py", line 2627, in _get
value, loc = self._do_get(name, group, namespace)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/oslo_config/cfg.py", line 2645, in _do_get
info = self._get_opt_info(name, group)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/oslo_config/cfg.py", line 2845, in _get_opt_info
raise NoSuchOptError(opt_name, group)
oslo_config.cfg.NoSuchOptError: no such option iteritems in group [DEFAULT]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/bush/Desktop/TestIOS/TestPython/testDemo01/testDemo01/test16.py", line 15, in <module>
res = [{k:v} for k, v in cfg.CONF.iteritems()]
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/oslo_config/cfg.py", line 2197, in __getattr__
raise NoSuchOptError(name)
oslo_config.cfg.NoSuchOptError: no such option iteritems in group [DEFAULT]
Upvotes: 0
Views: 1414
Reputation: 26896
In newer version of oslo_config.cfg
, you can use items()
for your purpose:
es = [{k:v} for k, v in cfg.CONF.items()]
pprint(res)
Upvotes: 1