Python

Splitting a numeric code in Python

by Drew Leske, 9 April 2025

Sometimes people do funky things with data. We have a use case where two two-digit codes are mashed together into a four-digit code, and we need to split them. These codes are stored as integers because, well, why not.

To Mock or Not to Mock - Mocking Unit Tests

by Lee Napthine, 14 March 2025

If you’ve ever written unit tests, you’ve probably encountered situations where a function depends on an external API, a database, or a cloud service. These things are difficult to control in a test environment. This is where mocking comes in.

Using syntax trees in Python

by Bhavy Rai, 2 July 2024

In this article we describe how a need for parsing Python files led us on a journey starting with plain text parsing, to abstract syntax trees, and then finally to where we wound up with conrete syntax trees, and the lessons we learned along the way.

Splitting a string list in Python

by Drew Leske, 5 March 2024

I’m definitely a fan of list comprehensions in Python (as well as dict comprehensions), but I have some pretty specific ideas about how they should be formatted to be readable. Dict comprehensions are more complex, but even the much simpler list comprehensions can be abused, or misleading even when used well.