def __enter__(self): _, _, _, env_locals = inspect.getargvalues(inspect.currentframe( ).f_back) self.__dict__['_env_locals'] = env_locals.keys()