Posts tagged: python

All posts with the tag "python"

268 posts latest post 2026-03-31
Publishing rhythm
Jan 2026 | 3 posts

First 3d Printed Threads

Working on an upcoming project that requires some threaded screws. Trying to keep a low budget on this one with as much to come off of the printer as I can. It might become a slant3d portals product if it works out. I always like making test prints for stuff like this especially to see how the feel is off of the printer that is going to print the final product and take much longer. First try was a success.

I started out looking up standard half inch thread pitch and size, but ran out of time to get the exact profile of a half inch bolt, so I will need to fix that later. Th

The print orientation is critical for strength here. This part is a full 1/2: so it should be strong either way, but to make sure we are printing the bolt horizontally to get nice long print layers. To do this we have to give it a bit of a flat spot on the top and bottom. This does not hurt performance, if anything it probably helps give some room for poor tolerances.

2 min read

FastAPI is a modern and efficient web framework for Python, built on top of the Starlette web framework, and pydantic for data validation and serialization.

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.

The key features are:

The +5 point increase for FastAPI is one of the most significant shifts in the web framework space. This signals a strong trend towards using Python for building performant APIs and reflects the overall strength of the Python ecosystem.

FastAPI.">Starlette has a head request that works right along side your get requests. This morning I fiddled around with custom routes for GET and HEAD, but had to manually set some things about the file, and was still missing e-tag in the end. Turns out as a developer you can just add a head route to your get routes and starlette will strip the content for you, while preserving all of those good headers that fastapi FileResponse created automatically for you.

...

python extras are for shipping

Python has two ways of adding optional dependencies to your projects pyproject.toml file dependency-groups and optional-dependencies.

for development

Dependency grooups are used when working on the project, they do not ship with the project, users cannot select to install them with the project. These are for things like running tests, linting, or docs. You might want to run these in ci, or keep your dev machines tight. For the most part you can probably keep these in dev. Depending on your team, fluency, and tolerance for slower installs extra packages. Adding too many tight groups might make it hard for the team to remember all the groups and which one to use and end up with them using --all-groups anyways.

...

3 min read

anthony has some of the best python highlight videos each year. This might be a good sign, but each year there seems to be less and less that I am chomping at the bit to get to. I thought the remote debugger looked every interesting, his use case for babi seemed very interesting. I wonder what textual would look like built in a 3.14 world, would it still have built its own debugger/console?

uv tool run --python=3.14 babi

Without a process flag you need sudo permissions to attach a pdb debugger similar to gdb.

Kraft-Coordinates

Handy reference for coordinates in the kraft world.

Overworld:-208 71 -291 Nether:-26 9 -36

Overworld: 209 62 -752 Nether:26 1 -94

1 min read

PEP 735 describes dependency groups as sets of optional dependencies that are not shipped with the package but intended for development purposes.

The PEP includes an example for groups that include test, docs, typing, and a combo typing-test.

[dependency-groups] test = ["pytest", "coverage"] docs = ["sphinx", "sphinx-rtd-theme"] typing = ["mypy", "types-requests"] typing-test = [{include-group = "typing"}, {include-group = "test"}, "useful-types"]

This is implemented in uv and can be used by several of their commands.

uv sync --group test uv run --group test uv add --group test pytest uv remove --group test pytest uv export --group test uv tree --group test

Dependency Groups are not Extras #

The docs describe extras as being intended to ship with the application and dependency groups intended for development. The spec allows both to exist with the same name, but care should be taken as tools may have different implementations.

...

I smell a dependency to python-dotenv dying in my workflow. I originally read the title of the post and thought, “I know how to manage .env and almost skipped it”. I’m leaning more and more on uv run these days, so this should just go in my [[ just file ]] to make it easy to run.

zmk two hand hold down

I don’t know about you, but I don’t re-flash my keyboard enough to ever remember where I put the bootloader. Sometimes its the last thing I think about in a refactor and I end up cornering myself into a place where I cant get into that layer anymore. I’ve started putting hardware switches on my newer builds, but some older builds don’t have a hardware one, so it requires disassembly and jumping the microcontroller. Even when I have one though, I gotta flip my board over and its annoying sometimes, so I prefer to have a keystroke for it.

What I’ve landed on recently is the idea of a two hand hold down combo for the bootloader. These combos are ones that there is no way I can hit without picking my hands up from their normal homerow position and pressing four keys simultaneously with pointer and thumbs.

Here are some example layouts from keymap-editor

...

2 min read

I’ve been leaning on lazy-self-installing-python-scripts more and more, but I did not realize how much tooling that uv gives you to help manage your scripts.

uv init --script up uv add --script up typer rich uv remove --script up rich sed -i '1i #!/usr/bin/env -S uv run --script' up chmod +x up ./up

The result is a script that looks like this, its executable as what looks like regular command in your shell.

Keycap Cut Away

I was curious how/if my custom keycap design was hitting my switches. So I set out to find out what the fitup inside of this assembly looks like, but not theoretically, a fully sliced view into their fit up in the flesh.

To setup for this cut, I flooded the edge of a 2x4 with hot glue, and inserted the cap such that the step was tangent with the edge. This way I could use the edge as a guide to cut one side off and leave the stem in tact. I took a handsaw to it and filed it smooth.

Removal was applying some isopropyl alcohol and it popped right off.

...

1 min read

I have a couple of use cases for simple qr codes in python coming up. One is for blog posts, the other is for auth into a new server application logged to a terminal. I tried the qrcode library and it does not look as nice to me and I found pyqrcode to be quite nice.

import pyqrcode url = pyqrcode.create('https://waylonwalker.com/qr-codes-in-python') url.svg('qr-codes-in-python.svg', scale=8) print(url.terminal(quiet_zone=1)) url.svg('qr-codes-in-python.svg', scale=12) url.svg('qr-codes-in-python.svg', omithw=True) # width is controlled by the container url.svg('qr-codes-in-python.svg', omithw=True, module_color='#ffd119') url.svg('qr-codes-in-python.svg',...

...

Such a fantastic use of uv, its so fast and flexible and does everything I need that next time I go to set up some more complex testing like this I’m going to lean towards it more than i would something like tox. In the post Daniel sets up matrix testing for testing out different versions of python with the same pytest test suite.

I’ve been a long user of pygments, it’s been the thing that injects <spans> with funny little class names like sc and si into the code blocks of my website. I’ve even gone as far as implementing a plugin for md-it, but I had no idea how to re-style it. I long ago got a theme that looked good enough from somewhere and just used it, maybe I pulled something from their docs site and forgot. Today I learned you can list all the themes easily from the library itself, and render out new css.

from pygments.styles import get_all_styles list(get_all_styles()) # [ # 'abap', # 'algol_nu', # 'algol', # 'arduino', # 'autumn', # 'borland', # 'bw', # 'colorful', # 'default', # 'dracula', # 'emacs', # 'friendly_grayscale', # 'friendly', # 'fruity', #...

markata parallel render

_._ __/__ __ __ _/_ Recorded: 07:53:56 Samples: 71681 /_//_/// /_\ / //_// / //_'/ // Duration: 92.741 CPU time: 91.748 /_/ v4.5.1 Program: /home/waylon/git/waylonwalker.com/.venv/bin/markata build --pdb 92.740 Markata.run markata/__init__.py:443 `- 92.714 HookCaller.__call__ pluggy/_hooks.py:479 [2 frames hidden] pluggy 92.714 PluginManager._hookexec pluggy/_manager.py:106 |- 38.207 wrapper_register markata/hookspec.py:265 | |- 26.105 render plugins/link_collector.py:59 | | |- 10.012 BeautifulSoup.__init__ bs4/__init__.py:122 | | | [14 frames hidden] bs4, html | | |- 5.599 <listcomp> plugins/link_collector.py:181 | | |- 4.050 <listcomp> plugins/link_collector.py:173 | | |- 3.466 Markata.map markata/__init__.py:565 | | |`- 2.092 markata/__init__.py | | `- 0.942 BeautifulSoup.find_all bs4/element.py:2008 | | [2 frames hidden] bs4 | |- 9.107 render markata/plugins/render_markdown.py:260 | |`- 8.902 result_iterator concurrent/futures/_base.py:612 | | [5 frames hidden] concurrent,...

csv

name,age,city Alice,30,New York Bob,25,San Francisco Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago name,age,city Alice,30,New York Bob,25,San Francisco Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago Charlie,35,Chicago graph TD A-->B A-->C A-->D D-->E document.addEventListener('DOMContentLoaded', function() { (function() { const ctx = document.getElementById('chartjs-1'); new Chart(ctx, { "type": "bar", "data": { "labels": ["Red", "Blue"], "datasets": [{ "label": "Votes", "data": [12, 19] }] }, "options": { "responsive": true } }); })(); (function() { const ctx = document.getElementById('chartjs-2'); new Chart(ctx, { "type": "line", "data": { "labels": [ 65, 59, 80, 81, 56, 55, 40 ], "datasets": [ { "label": "My First Dataset", "data": [ 65, 59, 80, 81, 56, 55, 40 ], "fill": false, "borderColor": "rgb(75, 192, 192)", "tension": 0.1 }...

David’s design on his blog is fantastic likely from years of small improvements like this converting ugly quotes to pretty quotes and optimizing fonts.

It’s common for markdown libraries to convert the first to the second like my build script does.

This is new to me, I had no idea that markdown libraries did this, I’m now interested if markdown-it does it.

For subsetting I use the fontTools library but I’ve no idea how to setup Python environments. I got it working once and failed to document the process.

...