def flatten(current, key, result):
if isinstance(current, dict):
for k in current:
new_key = "{0}.{1}".format(key, k) if len(key) > 0 else k
flatten(current[k], new_key, result)
else:
result[key] = current
return result
result = flatten(my_dict, '', {})
print(flatten(_dict1, '', {}))
{'this.example.too': 3, 'example': 'fish', 'this.is.another.value': 4, 'this.is.an.example': 2}