My Python Library


My Python Library

During my research for the book “Learn Python the Hard Way” I stumble often over good websites/ressources that help me solve some problems. Here I will make a growing list of it as a library for me but also for you to use. Feel free to make your own library below.

General Python

The Hitchhiker’s Guide to Python!

It helps you with a lot of topics related to Python. Like installing, virtual environments, packaging, testing, code structuring, etc. It’s a really good start if you want to research a new topic in Python.

Quote from their Website:

This handcrafted guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.



Thanks to @donal_m I found this site, that is a good reference when you have to look up string formatting in Python.

Quote from the website:

Python has had awesome string formatters for many years but the documentation on them is far too theoretic and technical. With this site we try to show you the most common use-cases covered by the old and new style string formatting API with practical examples.


Mouse vs. Python: Python 3 Testing - An Intro to unittest

Very clear and down-to-the-earth explanation of what unittest does. This article helped me a lot to find my way into the understanding how to use tests.

Quote from the article:

The unittest module is actually a testing framework that was originally inspired by JUnit. It currently supports test automation, the sharing of setup and shutdown code, aggregating tests into collections and the independence of tests from the reporting framework.

Python 2 vs. Python 3: Which LPTHW book should I get?


Getting Started with Mocking in Python - a Blog Post

Simple and easy explanation of unittest.mock with some very clear and understandable examples without any unnecessary overhead. Helped me a lot.

Quote from the article:

An introduction to using Python’s unittest.mock for replacing parts of your system under test and improving the efficiency of your unit tests.



Official Flask Tutorial

Arrived at the end of Ex50 of LPTHW I headed over to the docs section of flask. Hanging around in the Quickstart section and missign some basic things there I later found the tutorial site via google. It’s better to start there. Here it is:

Quote from the tutorial:

This tutorial will walk you through creating a basic blog application called Flaskr. Users will be able to register, log in, create posts, and edit or delete their own posts. You will be able to package and install the application on other computers.

The Flask Mega-Tutorial

I just found it. Haven’t done any work on it. But it looks promising. Then I will decide to use Flask for a future project, this will be on my list first.

Quote from the tutorial:

Welcome! You are about to start on a journey to learn how to create web applications with Python and the Flask framework. In this first chapter, you are going to learn how to set up a Flask project. By the end of this chapter you are going to have a simple Flask web application running on your computer!



Python Argparse Cookbook

Ex04 on Learn More Python the Hard Way requires to work with the Argparse module. While the official Python documentation is very good as a technical documentation I often fail to gain some applicable advice from it. The Argparse description was no exeception. I found a blog post from Marcus Kazmierczak that helped me a lot to bring my own program to live. Maybe it will help you too.

And here the link to the official docs:

And here a link to the official argparse tutorial:


Google python-fire

Automatically Generate Command Line Interfaces

Accidentally found this promising python module today. It’s a easy way to create a command line interface for any Python object.



Python 3’s pathlib Module: Taming the File System

In Learn More Python the Hard Way Zed leads you to the Python pathlib Module. Later, when I wrote some scripts I realized that it is VERY handy to accomplish stuff where you need to have access to and working with the filesystem of your computer. On Real Python I found a well presented tutorial with some cool code snippets that get’s you started.


Executable Scripts

How Do I Make My Own Command-Line Commands Using Python?

During the last years I put a lot of notes about programming and how to archive things with my computer. Among others there are a lot of usefull vim commands, how to install programms, etc, etc.
After trying a lot of tools to order my content, ranging from a private MoinMoin-Wiki to a bunch of note taking apps (Evernote, MyNotex, MedleyText) I finally decided to go with good old school blank .md files in a directory tree.

It is searchable with the command line or the finder, version controlled with Git and always available on all of my devices with a private GitHub-Repository. What do you want more?

The only thing I missed was index of all of my content. So I wrote a script that walks through my docs and outputs a with a nice index with relative links. With that I have always a 10’000 feet view of my content.
After writing or updating my docs I just have to double click my Python script and the job is done. Nice!

To accomplish the later part I had to find a way to turn my script in a executable file. How to do this is nicely explained in this tutorial from Dan Bader:


Cool stuff, Didier!
Thanks for sharing.