Interpreter Customization Hooks

usercustomize

Optional per-user startup module attempted by site when user-site support is enabled. It is not guaranteed to exist. Avoid modifying or importing a real hook just to inspect it. The example is a proposed synthetic source-inspection fixture, not an actual hook import.

Formal Syntax & Structure

python syntaxpython
import usercustomize

Return Value

module

Optional installation-defined module; importing may execute its contents.

Working Example

Example Snippetpython
from pathlib import Pathfrom tempfile import TemporaryDirectoryimport astwith TemporaryDirectory() as folder:    path = Path(folder) / "usercustomize.py"    path.write_text("label = \"demo\"\n", encoding="utf-8")    print(ast.parse(path.read_text(encoding="utf-8")).body[0].targets[0].id)
Python Reference