Other articles


  1. Why you should write your tools in Python Again

    You're probably thinking that there are already plenty of tools written in Python.

    But I see that most of the popular tools like mypy and flake8 are built for development environments. In contrast, general purpose cli tools tend to be built in other languages, for example most of the docker …

    read more
  2. Sqlalchemy Footgun: Discarding the statement

    This one has frustrated me for a while.

    It starts off with a REST API route. For example in fastAPI

    @app.get("/")
    def search_users(session: Session) -> list[User]:
        """Finds users optionally filter by user_id"""
        statement = select(User).order_by(User.name)
        return session.execute(statement).scalars().all()
    

    Then we get asked …

    read more
  3. Jamie's Pattern Matching Cookbook

    Structural pattern matching is probably the coolest new syntax introduced to Python. Added in 3.10, it's been a few years now and more people are writing apps in 3.10* than any other version now.

    Though even with the wide adoption of 3.10 and more people being exposed …

    read more
  4. Customising Pattern Matching Behaviour

    I've been doing advent of code again this year. There are two Python features I always rely on, iterators and pattern matching. Iterators allow for operations on each of its elements without allocating memory for a collection. Ever since pattern matching was introduced in Python 3.10, it's been particularly …

    read more
  5. Python-in-Python Sandboxing LLM Generated Code

    I've been experimenting with Langchain for GPT based queries. One problem we often encounter with GPT is hallucinations. This makes certain classes of problems unsuited to GPT, one example is maths and statistics. Whilst there are improvements for recent models often the maths cannot be trusted.

    When I try to …

    read more

social