I know how to add a function to a python dict:
def burn(theName):
return theName + ' is burning'
kitchen = {'name': 'The Kitchen', 'burn_it': burn}
print(kitchen['burn_it'](kitchen['name']))
### output: "the Kitchen is burning"
but is there any way to reference the dictionary's own 'name' value without having to name the dict itself specifically? To refer to the dictionary as itself?
With other languages in mind I was thinking there might be something like
print(kitchen['burn_it'](__self__['name']))
or
print(kitchen['burn_it'](__this__['name']))
where the function could access the 'name' key of the dictionary it was inside.
I have googled quite a bit but I keep finding people who want to do this:
kitchen = {'name': 'Kitchen', 'fullname': 'The ' + ['name']}
where they're trying to access the dictionary key before they've finished initialising it.
TIA