You can use getattr:
data = getattr(config, config.WhichOneof('config')).value
Since WhichOneof('config') returns either 'a' or 'b', just use getattr to access the attribute dynamically.
You can use getattr:
data = getattr(config, config.WhichOneof('config')).value
Since WhichOneof('config') returns either 'a' or 'b', just use getattr to access the attribute dynamically.