libconfig.Config.on_option_value

Config.on_option_value(*args)

Temporarily change the configuration values.

Raises:
ValueError:If the number of parameters cannot be casted into one or multiple options.
In [1]: from libconfig import Config
   ...: c = Config()
   ...: c.register_option('opt', 'on', 1, 'int', 'option 1')
   ...: c.register_option('opt', 'tw', 2, 'int', 'option 2')
   ...: print('opt.one', c.get_option('opt', 'on'))
   ...: with c.on_option_value('opt', 'on', 10):
   ...:     print('with opt.one', c.get_option('opt', 'on'))
   ...: print('opt.one', c.get_option('opt', 'on'))
   ...: print('opt.two', c.get_option('opt', 'tw'))
   ...: with c.on_option_value('opt', 'on', 10, 'opt', 'tw', 20):
   ...:     print('with opt.one', c.get_option('opt', 'on'))
   ...:     print('with opt.two', c.get_option('opt', 'tw'))
   ...: print('opt.one', c.get_option('opt', 'on'))
   ...: print('opt.two', c.get_option('opt', 'tw'))
   ...: c.unregister_option('opt', 'on')
   ...: c.unregister_option('opt', 'tw')
   ...: 
opt.one 1
with opt.one 10
opt.one 1
opt.two 2
with opt.one 10
with opt.two 20
opt.one 1
opt.two 2