Runtime Data Attributes

code.co_name

Short name stored in the compiled code. Changing a function's __name__ does not change its code object's name.

Formal Syntax & Structure

python syntaxpython
code.co_name

Return Value

str

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

Working Example

Example Snippetpython
def f(): return 7code = f.__code__print(code.co_name)
Python Reference