Runtime Data Attributes

code.co_flags

Bitmask describing execution features such as generator and variadic parameter flags. Use named inspect constants rather than relying on undocumented bits.

Formal Syntax & Structure

python syntaxpython
code.co_flags

Return Value

int

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

Working Example

Example Snippetpython
import inspectdef f(*args): yield argscode = f.__code__print((bool(code.co_flags & inspect.CO_GENERATOR),bool(code.co_flags & inspect.CO_VARARGS)))
Python Reference