← All lessons

Project structure

Sign in · Sign up

Lesson 13.4

A big project is split into parts:

my_project/
├── main.py          # the entry point: the program starts here
├── utils.py         # helper functions
├── data/
│   └── notes.json   # data kept apart from the code
└── README.md        # the project description: what it is and how to run it
  • main.py is the entry point: you run it, not every file;
  • utils.py is your own module, imported with import utils;
  • data/ holds the data, so the code and the files are not all in one pile;
  • README.md is a one-page description: without it nobody knows what the project is;
  • the import has no .py: import utils, not import utils.py.

The check puts the module project next to your program — a little "project folder". It has PROJECT, a dictionary of files and their roles: "main": "entry point".

Print the project structure:

  1. Project: <name> — the name taken from project.PROJECT["name"];
  2. Files: and one item - <file>: <role>.

The keys of the "files" dictionary are file names, the values are roles.

Hint

Looping over a dictionary gives the keys, the value is taken by key.

First the project name from project.PROJECT["name"], then the heading Files: and a loop: the file name, a colon and the role from the nested dictionary.