Runtime Data Attributes

cell.cell_contents

Read or replace the binding held in a closure cell. Reading an empty cell raises ValueError; changing a shared cell affects functions closing over that cell.

Formal Syntax & Structure

python syntaxpython
cell.cell_contents

Return Value

object

Value exposed by this attribute; availability and mutability depend on the owner as described.

Working Example

Example Snippetpython
def outer():    x = 7    def f(): return x    return ff = outer(); cell = f.__closure__[0]print(cell.cell_contents)
Python Reference