I have a dictionary:
D = { "foo" : "bar", "baz" : "bip" }
and I want to create new dictionary that has a copy of one of it's elements k
. So if k = "baz"
:
R = { "baz" : "bip" }
what I've got now is:
R = { k : D[k] }
But in my case k
is a complex expression and I've got a whole stack of these. Caching k
in a temporary looks about as ugly as the original option.
What I'm looking for is a better (cleaner) way to do this.