Lo-Fi Python

Feb 23, 2022

6 Must-read Python Enhancement Proposals (PEPs)

These are a few of my favorite PEPs, or Python Enhancements Proposals I've encountered recently. PEP 0, PEP 8 and PEP 20 are great reads for those aspiring to hone their Python skills. The documentation sometimes references specific PEPs directly also. They document Python's evolution over time and the rationale behind it. Here are some good ones to remember!

PEP 0 -- Index of Python Enhancement Proposals

PEP 8 -- Style Guide for Python Code

PEP 20 -- The Zen of Python

PEP 249 -- Python Database API Specification v2.0

PEP 3131 -- Supporting Non-ASCII Identifiers

PEP 3333 -- Python Web Server Gateway Interface v1.0.1

Sep 23, 2021

What I Learned from Black, Python's "Uncompromising" Code Formatter

Black is a code formatting tool that I have been testing out recently to see what the hype is about. It is the defacto "uncompromising code formatter in Python". I normally do not use any code formatters since I'm not required to use them. This short post aims to convince you that Black is an insightful way to see the parts of your code that are dangerously unreadable.

I have found it interesting to see what black does with my gnarliest code. It has taught me what is considered "good formatting" by some Pythonistas. The areas where I see the most improvement is how it enforces PEP-8's characters per line limit. Often before, I didn't know how to break my code into several lines. My scripts tended to have one-liners trailing off the edge of my text editor. Black teaches you new ways to organize your code and makes it easier to understand. Now I write my code like Black the first time instead of letting it trail off the screen.

Initially I was hesitant to try Black because I didn't want to sabotage my own code style. But since running Black on a few of my scripts, it has taught me new ways to write code. Give Black a chance and you will learn how to write more readable Python.

Here's the project on GitHub: https://github.com/psf/black