Runtime Data Attributes

function.__code__

Compiled body associated with a Python function, distinct from its defaults and globals. Compatible code can replace it; closure cell counts must match.

Formal Syntax & Structure

python syntaxpython
f.__code__

Return Value

types.CodeType

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

Working Example

Example Snippetpython
def f(): return 7def g(): return 9print(f.__code__.co_name)
Python Reference