A dictionary that returns the key as the value by default can be used in cases where exceptions or translation is needed.
E.g. One could do
i18n = SpecialDict()
if spanish:
i18n["Hello"] = "Hola"
print(i18n["Test"]) # prints Test
print(i18n["Hello"]) # prints Hola if spanish
I18n is just an example, there are other (probably better) uses.
Is there a name for this dictionary / pattern?
Edit
Wow, I did not expect such a backsplash. Just to make it clear, this type of dictionary is not "defective" or "broken". It is a simple and elegant solution for a specific type of problem, and I have used this pattern with great success in my career. If you fail to see a usage for this then please move along to another question.
As for gnat's comment, I was not aware that questions like this are not welcome here. I'm sorry for that. I would delete my question but there is already an answer (which actually does not answer my question at all) so I'll just flag it for closure.
Edit 2
Since I have not found a name or usage of this, and this (sadly short-lived) question did not bring up anything either I hereby name this pattern
Data Aspect
and the dictionary-like object a
Data Aspect Map
I would love to post an answer to this question with a more detailed definition, description and maybe some examples and welcome feedback to this pattern, but I can't, since this question is on hold.