Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

1 matching syntax entry

Imports and the entry point

Learn in depth →

Import locates and initializes a module, normally caching it in sys.modules. __name__ identifies its execution context.

import package.module
if __name__ == "__main__": ...

Example

import math
print(math.isqrt(17))

Result

4

Watch for: A local file named like a standard module can shadow it. An import may execute module-level code.

Practise this topic →
Complete explanation index (91 lessons indexed)

Modules, Packages & What import Really Does

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.