python

105 posts tagged “python”.

  1. 2025
  2. Installing lxml for Python on an M1/M2 Mac

    I ran into this error while trying to run on an M2 Mac, inside a virtual environment I had intitially created using : I eventually realized that this was using the system Python - - which doesn't have…

    1 min read
  3. Understanding option names in Click

    I hit a bug today where I had defined a Click option called but in doing so I replaced the Python bulit-in function: This inspired me to finally figure out how Click function argument names work.

    1 min read
  4. Programmatically comparing Python version strings

    I found myself wanting to compare the version numbers , and the in Python code, in order to mark a test as skipped if the installed version of Datasette was pre-1.0.

    1 min read
  5. Checking if something is callable or async callable in Python

    I wanted a mechanism to check if a given Python object was "callable" - could be called like a function - or "async callable" - could be called using .

    1 min read
  6. Password hashing in Python with pbkdf2

    I was researching password hashing for datasette-auth-passwords. I wanted very secure defaults that would work using the Python standard library without any extra dependencies.

    1 min read
  7. Configuring GitHub Codespaces using devcontainers

    GitHub Codespaces provides full development environments in your browser, and is free to use with anyone with a GitHub account.

    3 min read
  8. Creating a minimal SpatiaLite database with Python

    When writing a test for datasette-leaflet-freedraw I realized I didn't have a simple tiny recipe for creating an in-memory SpatiaLite database in Python.

    1 min read
  9. Protocols in Python

    Datasette currently has a few API internals that return objects. I was thinking about how this might work in the future - if Datasette ever expands beyond SQLite (plugin-provided backends for…

    1 min read
  10. struct endianness in Python

    TIL the Python standard library struct module defaults to interpreting binary strings using the endianness of your machine. Which means that this code: Behaves differently on big-endian v.s.

    1 min read
  11. Using tree-sitter with Python

    tree-sitter is a "parser generator tool and an incremental parsing library". It has a very good reputation these days.

    1 min read
  12. Automatically maintaining Homebrew formulas using GitHub Actions

    I previously wrote about Packaging a Python CLI tool for Homebrew. I've now figured out a pattern for automatically updating those formulas over time, using GitHub Actions.

    3 min read
  13. Asserting a dictionary is a subset of another dictionary

    Take for example an API endpoint that returns something like this: I want to efficiently assert against the second two keys, but I don't want to hard-code the SQLite version into my test in case it…

    1 min read
  14. actions/setup-python caching for setup.py projects

    I used to use a combination of and in all of my Python GitHub Actions projects in order to install Python dependencies via a cache, rather than hitting PyPI to download copies every time.

    1 min read
  15. Efficiently copying a file

    TLDR: Use I'm writing a Datasette plugin that handles an uploaded file, borrowing the Starlette mechanism for handling file uploads, documented here.

    1 min read
  16. Bundling Python inside an Electron app

    I used python-build-standalone for this, which provides a version of Python that is designed for easy of bundling - it's also used by PyOxidize.

    1 min read
  17. Format code examples in documentation with blacken-docs

    I decided to enforce that all code examples in the Datasette documentation be formatted using Black. Here's issue 1718 where I researched the options for doing this. I found the blacken-docs tool.

    1 min read
  18. Embedding JavaScript in a Jupyter notebook

    I recently found out modern browsers include a JavaScript API for creating public/private keys for cryptography.

    1 min read
  19. Using io.BufferedReader to peek against a non-peekable stream

    When building the –sniff option for (which attempts to detect the correct CSV delimiter and quote character by looking at the first 2048 bytes of a CSV file) I had the need to peek ahead in an…

    1 min read
  20. ---

    — A one-liner to output details of the current Python's SQLite 2025-10-19 Farshid Ashouri TIL,sqlite In investigating llm/issues/164 I found myself needing to know more precise details of the Python…

    1 min read
  21. Simple load testing with Locust

    I've been using Locust recently to run some load tests - most significantly these tests against SQLite running with Django and this test exercising Datasette and Gunicorn.

    1 min read