Hey, check out my Modern Python Projects course. It's an extended version of this workshop!

Exercise 2

TODO Application

The final exercise is to write a small project in Python using the tools and ideas that we learned today. Let’s create a TODO app.

Your TODO application should implement the following features:

  • Show a list of tasks
  • Add a new task
  • Mark task as done
  • Delete a task (without marking it as done)

Apart from writing the code, I would like you to also:

  • Write tests
  • Document your functions
  • Generate documentation with Sphinx
  • Install flake8 and black and run your code through those tools
    • As a bonus point - configure VS Code to use flake8 and black automatically

How to start

While you can start working entirely from scratch, I have prepared a cookiecutter template for you: https://github.com/switowski/modern-python-workshop-cookiecutter.

After you installed cookiecutter, create your project with this template:

$ cookiecutter https://github.com/switowski/modern-python-workshop-cookiecutter

It will ask you a few questions, the most important ones are:

Select start_from: 1 - Scaffolding 2 - Empty files

If you select the “1 - Scaffolding” option, the cookiecutter will generate a pretty comprehensive scaffolding for you. It will take care of setting up everything (the Flask app, database with the models, fixtures for tests). Your tasks will be to finish the functions, add tests, and documentation.

This is a recommended option if you don’t know Flask, if you haven’t used it in a long time, or if you just want to focus on the core part of the exercise and not bother with setting up everything yourself.

If you select the “2 - Empty files” option, the cookiecutter will generate files that are mostly empty with a bunch of “TODO” comments. The main reason why I’m generating those files for you is to enforce some structure. A simple app in Flask can be written in a single file, but the main point of this exercise is to learn how to split your project into separate pieces.

generate_html [y]: y

If you select the default option (“y”), it will generate an HTML template file for you that uses a simple bootstrap styling. I suggest that you leave it as it is.