Runtime Data Attributes

code.co_consts

Constants referenced by compiled code, including nested code objects where applicable. Compiler optimizations can alter the contents and positions.

Formal Syntax & Structure

python syntaxpython
code.co_consts

Return Value

tuple

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

Working Example

Example Snippetpython
def f(): return 42code = f.__code__print(42 in code.co_consts)
Python Reference