compact() and extract() are functions in PHP I find tremendously handy. compact() takes a list of names in the symbol table and creates a hashtable with just their values.
You can do this (though I would suggest only sparingly...) with the locals()
function, which returns an updatable dict
. Example:
$ python
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
>>> locals().update({'derek':'anderson'})
>>> derek
'anderson'
>>>
So locals()
would be "compact all" and locals().update()
would be extract
.
Best of luck!