def openscope(self, customlocals=None):
'''Opens a new (embedded) scope.
Args:
customlocals (dict): By default, the locals of the embedding scope
are visible in the new one. When this is not the desired
behaviour a dictionary of customized locals can be passed,
and those locals will become the only visible ones.
'''
self._locals_stack.append(self._locals)
self._globalrefs_stack.append(self._globalrefs)
if customlocals is not None:
self._locals = customlocals.copy()
elif self._locals is not None:
self._locals = self._locals.copy()
else:
self._locals = {}
self._globalrefs = set()
self._scope = self._globals.copy()
self._scope.update(self._locals)
评论列表
文章目录