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.
PHP's compact function in Python (works with 2.6; not guaranteed to work with earlier versions of Python):
import inspect
def compact(*args):
return dict([(i, inspect.currentframe().f_back.f_locals.get(i, None))
for i in args])
I've written more extensively about this: Python can be just as ugly as PHP.