Controlling the style of dumped YAML using PyYAML
I had a list of Python dictionaries I wanted to output as YAML, but I wanted to control the style of the output.
105 posts tagged “python”.
I had a list of Python dictionaries I wanted to output as YAML, but I wanted to control the style of the output.
I finally got around to fully learning TOML. Some notes, including how to read and write it from Python. The data structure A TOML file is a document that contains a dictionary of key value pairs.
I needed to generate a grid calendar that looks like this (design by Natalie Downe): The Python standard library calendar module has a utility function that really helps here: Outputs:
I got a bug report concerning my sqlite-fts4 project running on PPC64 and s390x architectures. The s390x is an IBM mainframe architecture, which I found glamorous!
I've been using and for my Python packages for a long time: I like that it works without me having to think about installing and learning any additional tools such as Flit or pip-tools or Poetry or…
I figured out a really simple pattern for experimenting with new Python packages today: This command will work if you have uv installed and nothing else.
I puzzled over this one for quite a while this morning. I had this test that was failing with Windows on Python 3.11: The test checks that the option to my constructor deletes and re-creates the file.
Inspired by py-free-threading.github.io I decided to try out a beta of Python 3.13 with the new free-threaded mode enabled, which removes the GIL.
I've been wanting to figure out how to do this for years. Today I finally put all of the pieces together for it. AWS Lambda can host functions written in Python.
GitHub's Dependabot can automatically file PRs with bumps to dependencies when new versions of them are available.
Here's how to format a number in Jinja with commas for thousands, without needing any custom filters or template functions: {{ "{:,}".format(row count) }} Output looks like this: 179,119 Bonus: here's…
PyInstaller can take a Python script and bundle it up as a standalone executable for macOS, Linux and apparently Windows too (I've not tried it on Windows yet).
I tried pip-tools for the first time today to pin the requirements for the natbat/pillarpointstewards Django app. The pip-tools README is really good. Here's how I'm using it.
Towards Inserting One Billion Rows in SQLite Under A Minute includes this snippet: All I had to do was run my existing code, without any change, using PyPy.
I've been trying to figure this out for years. Previous notes include Using LD PRELOAD to run any version of SQLite with Python (Linux only), and Building a specific version of SQLite with pysqlite on…
Inspired by this tweet by Mike Driscoll I decided to try using Fabric to run commands over SSH from a Python script, using a public key for authentication.
For complicated reasons I found myself wanting to write Python code to resolve a graph of dependencies and produce a plan for efficiently executing them, in parallel where possible.
David Beazley on Twitter: So, I just published this deliciously evil spin on dataclasses. It's tiny and the resulting classes import about 15-20 faster than dataclasses.
Today I discovered codespell via this Rich commit. is a really simple spell checker that can be run locally or incorporated into a CI flow. codespell is designed to run against source code.
Seth Michael Larson pointed out that the Python module can be used as a CLI tool like this: This is a neat Python feature: modules with a block that are available on Python's standard import path can…