An experimental pip subcommand for the Python Launcher for Unix

There are a couple of things I always want to be true when I install Python packages for a project:I have a virtual environmentPip is up-to-dateFor virtual environments, you would like them to be created as fast as possible and (usually) with the newest version of Python. | Continue reading


@snarky.ca | 3 months ago

My proof-of-concept record type

Back in June, I proposed a struct syntax for Python. I shared the post on Mastodon and got some feedback. Afterwards I thought about what I heard and talked it over with some folks. I've now coded up a proof-of-concept to share to get some more feedback from people to | Continue reading


@snarky.ca | 3 months ago

State of standardized lock files: December 2023

Back in October, I released mousebender 2023.2. The biggest change was adding support for PEP 714 (which unless you're running a package index you don't need to know about it). The other small thing was adding ProjectFileDetails as a union of typed dicts to make it easier to writ … | Continue reading


@snarky.ca | 3 months ago

Introducing basicenum

In the summer of 2022, my partner was taking her machine learning course as part of UBC's Key Capabilities in Data Science certificate. I was Andrea's on-call tutor for any Python questions, so while Andrea was listening to lectures I decided to do a small project that I thought … | Continue reading


@snarky.ca | 3 months ago

Announcing microvenv 2023.5

In my blog post explaining how virtual environments work, I announced my project called microvenv. At the time, my only goal was to create a package which could create virtual environments in a minimal, fast way. But since then, I have expanded the API of the package to provide s … | Continue reading


@snarky.ca | 3 months ago

Why I put in some effort to lower my carbon footprint

I was talking with someone about how Andrea and I have been consciously taking less flights since the pandemic started in order to lower our carbon footprint (Take the Jump suggests a flight under 1500km every 3 years, longer than that every 8 years; heard about this from David S … | Continue reading


@snarky.ca | 7 months ago

State of standardized lock files for Python: August 2023

Since people seemed to like my June 2023 post on the state of WASI support for CPython, I thought I would do one for another one of my other long-gestating projects: coming up with a standardized lock file format for Python packaging.💡When I say "lock file" | Continue reading


@snarky.ca | 8 months ago

Differentiating between writing down dependencies to use packages and for packages themselves

When my teammate Courtney evaluated various workflow tools for Python development to see how pip + venv compared, she came back with a recommendation on using pip's requirements files as a way to record what people installed (and thus needed to run their code). As someone wh … | Continue reading


@snarky.ca | 8 months ago

State of WASI support for CPython: June 2023

I wanted to give an update on where WASI support for CPython stood today and what I see happening in the future.💡If you don't know what WASI is or how CPython fits into it, please read my other blog post on WebAssembly platforms.TodayWASI is | Continue reading


@snarky.ca | 10 months ago

Proposing a struct syntax for Python

Story timeWhen I go on vacation with a fellow Python developer, inevitably I will talk about Python. 😁 Back in September, Andrea and I drove the Cabot Trail with our friends Dusty and Jen, which led to a discussion about the match statement and how Dusty and I both | Continue reading


@snarky.ca | 10 months ago

In response to the Changelog #526

In episode 526 of the Changelog podcast entitled, "Git with your friends", they discussed various tools involving git (disclaimer: I have been on the podcast multiple times and had dinner with the hosts of the podcast the last time they were in Vancouver). Two the proje … | Continue reading


@snarky.ca | 10 months ago

Unravelling `del`

In my post on unravelling the global statement, I mentioned how after my PyCascades 2023 talk some people came up to me about a couple of pieces of Python syntax that I had not managed to unravel. Beyond global, people thought I should be able to get rid of the | Continue reading


@snarky.ca | 1 year ago

Unravelling `global`

While preparing my talk for PyCascades 2023 on this very blog post series of Python's syntactic sugar, I had an inkling that I could unravel the global statement. After talking to some folks after my talk, I realized that I could, in fact, unravel it! The trick was | Continue reading


@snarky.ca | 1 year ago

How virtual environments work

After needing to do a deep dive on the venv module (which I will explain later in this blog post as to why), I thought I would explain how virtual environments work to help demystify them.Why do virtual environments exist?Back in my the day, there was no concept | Continue reading


@snarky.ca | 1 year ago

Use TOML for `.env` files?

We have some support for .env files in the Python extension for VS Code, but we have noticed some shortcomings with .env files based on user feedback. After getting some inspiration from CircuitPython and thinking about it a bit, I think I might have a nice solution to the proble … | Continue reading


@snarky.ca | 1 year ago

Testing a Python project using the WASI build of CPython with pytest

As part of bringing Python to the browser via vscode.dev, I looked into what it looks like today (January 2023) to test a Python project that uses pytest with a WASI build of CPython (see my post on WebAssembly and its various platforms if you don't know what "WASI" | Continue reading


@snarky.ca | 1 year ago

The many shapes and sizes of keyboards

Like many people in the programming industry, I work from home. And as such, I do not get up from my desk as much as I probably should as my office space is pretty comfortable. Unfortunately, this has led to my upper back getting a bit tight from slouching forward | Continue reading


@snarky.ca | 1 year ago

Classifying Python virtual environment workflows

I have been spending some time as of late thinking, and asking the community via the fediverse, about how people deal with virtual environments in Python. I have ended up with various ways of classifying people's virtual environment management and I wanted to write it all down to … | Continue reading


@snarky.ca | 1 year ago

WebAssembly and its platform targets

When talking about WebAssembly, one of the things that often confuses people is the lack of a great analogy for the various platform targets that WebAssembly supports. This ends up being a bit important as it dictates whether your WebAssembly code will (not) work with another bit … | Continue reading


@snarky.ca | 1 year ago

Unravelling `lambda` expressions

When I first wrote my series on Python's syntactic sugar, I left out lambda expressions as I knew I couldn't unravel them without unravelling assignment expressions. Luckily, I solved that problem, so now I can unravel lambda!If you read the language specification it tells you ho … | Continue reading


@snarky.ca | 1 year ago

Unravelling assignment expressions

As part of my series on Python's syntactic sugar, I initially skipped tackling conditional expressions because I made them more complicated than I needed to in my head. 😅 But there is some key subtlety to unravelling them which may not be obvious.Let's start with a simple … | Continue reading


@snarky.ca | 1 year ago

Unravelling `if` statements

After the initial posting of my summary post about my syntactic sugar series, I received the following reply to one of my tweets:🤔 wondering… ‘if/else’ (14 on your list) can be implemented in terms of ‘while’ (15 on your list)? something like this:run_else = Truewhile con … | Continue reading


@snarky.ca | 1 year ago

MVPy: Minimum Viable Python

Over 29 posts spanning 2 years, this is the final post in my blog series on Python's syntactic sugar. I had set out to find all of the Python 3.8 syntax that could be rewritten if you were to run a tool over a single Python source file in | Continue reading


@snarky.ca | 1 year ago

Unravelling Python's classes

For the second-to-last post in my syntactic sugar series (the final post will be a summary/conclusion post), I am tackling what I expect is my largest and most complicated: the class statement (although I'm too lazy to check if that statement is true 😁). Lucky for me, the … | Continue reading


@snarky.ca | 2 years ago

Unravelling ellipsis

... is the Ellipsis singleton. Shortest syntactic sugar blog post I have written. 😁 | Continue reading


@snarky.ca | 2 years ago

Unravelling literals

In this post of my syntactic sugar series, I want to tackle literals. Now some literals don't really require any code changes and are really just an alternative way to write the same thing, no call of code required (e.g. writing integers in hexadecimal format versus in base-10). … | Continue reading


@snarky.ca | 2 years ago

Unravelling subscriptions in Python

For the next post in my syntactic sugar series I want to cover subscriptions. It's quite possible you're not familiar with this formal term, but you are probably familiar with the syntax: the square brackets used for indexing lists and tuples (sequence[4]), accessing the value of … | Continue reading


@snarky.ca | 2 years ago

Unravelling `from` for `raise` statements

As part of my series on Python's syntax, I want to tackle the from clause for raise statements. In case you're unfamiliar, raise A from B causes B to be assigned to A.__cause__ which lets chained tracebacks exist (as well as __context__, but that's not relevant to today's topic) | Continue reading


@snarky.ca | 2 years ago

Unravelling `finally` and `else` from `try` statements

In the last post of my syntactic sugar series, I showed how you can get away with not having elif and else clauses on an if statement. It turns out you can use the same trick to help get rid of else clauses on try statements. And then there's another | Continue reading


@snarky.ca | 2 years ago

Unravelling `elif`/`else` from `if` statements

While I won't be attempting to unravel if statements entirely as part of my blog series on Python's syntactic sugar, I will be attempting to partially unravel them by showing how you don't need elif and else clauses. Unravelling elseLet's start with else . Semantically, else is r … | Continue reading


@snarky.ca | 2 years ago

Unravelling `break` and `continue`

I have previously unravelled for loops, and so the concept of looping has already come up in this blog post series of removing the syntactic sugar from Python. But one aspect of looping that I didn't touch upon is that of break and continue. Both are statements used to control | Continue reading


@snarky.ca | 2 years ago

A reverse chronology of some Python features

I occasionally hear people lament that Python is "bloated", "too big", "going enterprise", or some other phrasing to suggest there was once an "ideal" version of Python that had less bloat and was closer to what the person wanted. But then this lament is also often followed by, " … | Continue reading


@snarky.ca | 2 years ago

Selecting a programming language can be a form of premature optimization

Have you ever been told that Python couldn't be used for a project because it wouldn't be fast enough? I have, and I find it a bit frustrating as big banks, YouTube, Instagram, and plenty of other places that are performance-sensitive still manage to select Python and be happy. A … | Continue reading


@snarky.ca | 2 years ago

Unravelling decorators

For the next post in my syntactic sugar series, I thought I would tackle decorators. Let's look at a simple example of a function that has a single decorator applied to it. @decorator def func(): ...Decorator exampleIf you're familiar with decorators then your mental model fo … | Continue reading


@snarky.ca | 2 years ago

Unravelling data structure displays

The title of this next post in my series on Python's syntactic sugar may seem odd: what's a "display" when it comes to data structures? It turns out that's the technical term for what most folks would consider the literal form of lists, sets, and dictionaries. Comprehensions are … | Continue reading


@snarky.ca | 2 years ago

Unravelling comprehensions

After failing to unravel generator expressions, in this post as part as my Python syntactic sugar post series I want to tackle comprehensions. Thanks to a change made in Python 3.0, recreating comprehensions using generator expressions is straightforward since comprehensions do n … | Continue reading


@snarky.ca | 2 years ago

(Not) unravelling generator expressions

In this post on Python's syntactic sugar, I want to try to tackle generator expressions. If you look at the language definition for generator expressions you will see that it says, "[a] generator expression yields a new generator object" for what is specified (which is essentiall … | Continue reading


@snarky.ca | 2 years ago

Unravelling the `async with` statement

I already covered unravelling the with statement, and async with is not much different. Much like with, the language reference for async with gives an example of the statement already destructured. Based on that and the fact that async with is just with with asynchronous versions … | Continue reading


@snarky.ca | 2 years ago

Unravelling `async for` loops

When I decided the next post in my series on Python's syntactic sugar would be on async for, I figured it would be straightforward. I have already done `for` loops, so I have something to build off of. The language reference also specifies the pseudo-code for async for, so I | Continue reading


@snarky.ca | 2 years ago

Introducing the Python Launcher for Unix

The problemLet's say you have more than one version of Python installed on your machine. What version does python3 point to? If you said, "the newest version", you may actually be wrong. That's because python3 points at the last version of Python you installed, not necessarily th … | Continue reading


@snarky.ca | 2 years ago

What do you when you botch a release on PyPI

So you made a release on PyPI and there's a mistake (we've all been there). It can be as big as the whole release is bad, to just a spelling mistake in the README. Luckily there are things you can do to deal with various scenarios. The whole release is | Continue reading


@snarky.ca | 2 years ago

How I rate films

During the prerecording banter on the "Every commit is a gift" episode of the Changelog, we talked about films (which is no surprise considering I was an episode of Backstage all about the John Wick trilogy). I mentioned the rating system I used for films and Adam requested I blo … | Continue reading


@snarky.ca | 2 years ago

Unravelling `async` and `await`

For this post in my Python syntactic sugar series, I am going to cover async and await. Now when I started to think about this post I was worried it was going to be rather long and arduous to research (although I believe class is going to ultimately win that | Continue reading


@snarky.ca | 2 years ago

Unravelling the `with` statement

As part of my series on Python's syntactic sugar, I want to tackle unravelling the with statement. Looking at the bytecode for a simple with statement, you will notice there are a lot of opcodes being used. Most of it is managing the execution stack for the interpreter and dealin … | Continue reading


@snarky.ca | 2 years ago

Unravelling the `pass` statement

This is the next past in my series on Python's syntactic sugar. It's unfortunately been a while since my last post due to Python 3.10 and PyCon US 2021 taking up a lot of my time. But with those no longer being a distraction, I can get back into | Continue reading


@snarky.ca | 2 years ago

The social contract of open source

Even though I gave a keynote with an accompanying blog post all about setting expectations for open source participation, I felt it was time to do another blog post to directly address the issue of entitlement by some open source users which is hurting open source, both for thems … | Continue reading


@snarky.ca | 2 years ago

Unravelling `for` statements

As part of my series on Python's syntactic sugar, I am going to cover the for statement. As usual, I will be diving into CPython's C code, but understanding or even reading those parts of this post won't be required in order to understand how the unravelling works. The bytecodeLe … | Continue reading


@snarky.ca | 3 years ago

Unravelling assertions

In this post, as part of my series on Python's syntactic sugar, I'm going to cover assert statements. Now, the actual unravelling of the syntax for assert a, b is already given to us by the language reference: if __debug__: if not a: raise AssertionError(b)Implementat … | Continue reading


@snarky.ca | 3 years ago