Skip to the content.

Structuring a Python application

Starter, scaffold, or boilerplate code for projects developed mainly in Python. The note was inspired by a Real Python tutorial.

Common task — capture dependencies for both tests and code:

$ pip install -r requirements.txt

LICENSE information: if no license (file?) is included with the code, the code is fully copyrighted by default in most jurisdictions. This means no one has a right to use it or copy it in any fashion! I’m using MIT License for my Python templates.

One-off script

This template is for a single-file Python program, often called a script. It works both for code with or without dependencies.

To begin, generate a new repository using python-template-oneoff template repository.

To manage dependencies, create a virtual environment.

To run the unit test suite for the script:

$ python -m unittest tests.py

Installable single package

This template steps up in complexity. It is a multi-file Python module.

To begin, generate a new repository using python-template-single-package template repository.

To run the tests, there is a runtests.sh bash script:

Flask

TODO this template is an example of a multi-module Python program.

Django

TODO