Back to Modern Python Foundations

Project Structure & Packaging

Modern Python projects: src layout, pyproject.toml, uv. The 2026 way to organize code that ships. FIND_VIDEO: search 'python project structure pyproject toml uv' — recommended channel: ArjanCodes / mCoding. Aim for 10 min or under.

20 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Project Setup and Environment Isolation — Demonstrates why system Python should be isolated and configures a clean virtual environment using VS Code.
  2. Creating and Importing Modules — Explains that any Python source file is a module by importing a function from simple.py into main.py.
  3. Defining Package Directories — Introduces package directories as containers for modules and imports functions using dot-notation module paths.
  4. Exposing Functions with __init__.py — Shows how adding a dunder init file allows functions to be imported directly from the package namespace.
  5. Configuring pyproject.toml and Build Tools — Sets up PEP 518 package metadata and installs build dependencies to generate distribution artifacts.
  6. Building and Installing Local Wheels — Executes python -m build to create wheel archives and installs the resulting artifact into a second independent project.
PDF notes

Frequently asked questions

Why should I use a virtual environment instead of system Python?

A virtual environment isolates dependencies per project, preventing version conflicts and eliminating unnecessary bloat in the system Python installation.

Is __init__.py mandatory for importing submodules in Python 3?

While Python 3 supports implicit namespace packages without it, __init__.py is required to expose root package functions and enable standard package discovery tools.

What is the difference between a wheel (.whl) and a source distribution (.tar.gz)?

A wheel is a pre-built, ready-to-install package format, whereas a source distribution is an unbuilt archive containing raw source files.

Does pyproject.toml completely replace requirements.txt?

Yes, pyproject.toml acts as the single source of truth for package dependencies and build metadata in modern packaging workflows under PEP 518.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.