I personally would’ve slightly preferred .format
to take a mapping with a second signature but yeah a separate function/method is just fine in the end of day.
Thanks for the historical insight. The order does matter when keys in the input are inclusive of another. For example, with {'a': 'b', 'ab': 'c'}
, 'abc'
would be become 'bbc'
, but with {'ab': 'c', 'a': 'b'}
it would become 'cc'
.
This code isn’t quite equivalent to what is proposed because it wouldn’t support swapping as @Rosuav mentioned.