I think there's a lot of useful unexplored territory in this sort of tool. So much work nowadays is happening in maps/dictionaries/what-have-you, with a lot of work being, essentially, data shape transformation. Despite this, many languages aren't great at this! we have tools that work alright on first-order operations but fall apart on higher level things. Even really simple things like "conditionally include a key"…
Since you're using Python for your example, it's worth mentioning that 3.5 extended the unpacking syntax [1] to sort of do what you want. foo = { 'a': 1, 'b': 2, **({ 'c': 3, 'd': 4, } if bar else {}), } This adds `c: 3` and `d: 4` into `foo` conditional on `bar`. [1] https://docs.python.org/3/whatsnew/3.5.html#pep-448-addition...
Nice that this works on lists as well.