Skip to content
AgileLogics
4 min read

Code Organization

Prerequisites: Modules

As a project grows past one file, split it into modules grouped by responsibility, rather than one increasingly long main.py.

project/
    main.py
    models.py
    services.py
    tests/
        test_services.py

main.py then imports what it needs: from services import send_email. A useful rule of thumb: if a file is doing two unrelated things, split it into two files.