Concepts 🚀 Project 🧮 Labs
📚 Learn / Python / Modules & imports

Modules & imports

Each .py file is a module. from app.routes import notebook pulls in that module's names.

Code example

# app/routes/notebook.py
def _get_or_create_session(uid): ...

# app/main.py
from app.routes import notebook as notebook_route
app.include_router(notebook_route.router)

How it works

Python modules are just .py files. `import x` runs the file and binds the module name. `from x import y` runs the file and binds only `y`. Packages are directories with `__init__.py`. OpenBenchML uses absolute imports (`from app.routes import notebook`) — relative imports (`from . import notebook`) work too but are discouraged for top-level packages. The notebook route imports from app.config, app.database, app.routes.auth — a clear dependency tree.

🔍 Where this is used in OpenBenchML app/main.py imports every route module and includes its router.