I have a yaml file with test(s) configuration(s) and there is an optional parameter "ignore-dup-txn" in optional section "test-options".
test-name:
test-type: trh_txn
test-src-format: excel
test-src-excel-sheet: invalid_txns
test-options:
ignore-dup-txn: True
I read section "test-name" to "test" dict and for now I check it this way:
if 'test-options' in test and 'ignore-dup-txn' in test['test-options']:
ignore_dups = test['test-options']['ignore-dup-txn']
else:
ignore_dups = None
What would be the pythonic way to do it? More clear, simple and shorter.
I was thinking to do "getter", but if I do get(test['test-option']['ignore-dup-txn'])
, I will get an exception in case if option is not defined, obviously.
This would work: