liveBook · Manning

Directory structure

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

A directory is a filesystem container that organizes files and other directories under a name.

A directory is a named filesystem container for files and other directories. Nesting directories solves a practical naming problem: identical filenames can remain distinct when their directory paths differ. section 2.1.2

Directory structure turns a flat collection of files into an addressable hierarchy. The path acts as a layered namespace, so organization can grow from a simple root directory into deeper, more granular groupings. section 2.1.2 section 7.0

Separating expense reports

Suppose every expense report must be named expenses.xlsx. A root directory named expenses can contain one dated subdirectory per report, keeping identical filenames separate. If reporting volume grows, additional nested directories can provide finer-grained organization. section 2.1.2

Choose structure according to the amount of separation and growth the files require:

  • Use a single root directory when a small number of dated subdirectories is enough. section 2.1.2
  • Add deeper subdirectories when more granular separation is needed. section 2.1.2
  • Apply the same structural thinking to growing projects, where directories and namespaces help keep complexity manageable. section 7.0
Figure 2.1 Simple directory structure to manage expense reports

Use the simple directory diagram to compare a root directory with dated subdirectories. section 2.1.2

Figure 2.2 A more involved directory structure that provides more granular file separation

Use the more involved diagram to see how added levels provide finer file separation. section 2.1.2

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Explains the naming rationale, demonstrates a directory-design experiment, and visualizes hierarchy without implementation commands.
Examples
Uses identically named expenses.xlsx files, dated expense directories, and simple or granular hierarchy diagrams.
What you can do after
Build directory hierarchies that separate repeated filenames and scale from coarse to granular organization.
How it connects
Connects directories with filenames, subdirectories, namespaces, project structure, and application scalability.

Also explained in

Compare how 7 books explain directory structure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.