Runtime Data Attributes

function.__module__

Name of the defining module when available. Changing this metadata does not relocate the function or change its globals.

Formal Syntax & Structure

python syntaxpython
f.__module__

Return Value

str | None

Usual metadata value under ordinary construction; manually assigned metadata can differ. See description.

Working Example

Example Snippetpython
def f(): return 7print(f.__module__)
Python Reference