Thursday 03 December 2026 14:31:37 GMT+01:00

Netcrook

HomeManifesto
News
Techcrook
Geocrook
WikicrookTeamAppContact
EnglishItaliano

WIKICROOK

Python import system

The mechanism that loads modules and can run top-level code when a file is imported.

The Python import system finds and loads modules so their functions, classes, and variables can be used by other code. Importing a module also executes its top-level statements, unless the code is structured to avoid running those actions during import. This means an import can do more than make definitions available: it can read files, make network requests, or start other processes.

This behavior matters in security because imports happen in ordinary workflows, including application startup, tests, and build pipelines. A malicious or compromised module can use import-time code as an execution trigger, potentially acting with the permissions of the Python process. Review unfamiliar modules before importing them, inspect project configuration and dependency changes, and run untrusted code in an isolated environment with limited network access and privileges.

← WIKICROOK index