Dark Mode



Python Exceptions: Bonus Content

This post is a followup to my article The Basics of Exceptions in Python, but should make sense on its own as long as you are familiar with raise and try/except.

Let’s cover a few more advanced aspects of the Python exception system. We’ll move a bit faster and talk at a higher level than we did in the last post.

Topics we’ll hit:

The Basics of Exceptions in Python

This post was originally meant to be a small part of my discussion of the Go programming language (coming soon) as a way of drawing contrast between Python and Go, but turned out to be extensive enough to justify its own post.

Python’s model of exceptions is quite similar to that of other popular object-oriented languages like Ruby, JavaScript, and Java1. Errors flow differently than regular data; if not “handled”, they rise up through the entire function stack and crash the program. Developers are encouraged to write code to anticipate those exceptions, handle them before everything explodes, and change the logic flow of the program accordingly.

What exactly needs to be done in that “handling” step typically depends on what went wrong, and so there are many types of errors. Programmers can check the type of an error to determine what went wrong and react accordingly. Errors can be thought of as objects and their types as classes that can be subclassed like any other class. But unlike other data, they follow an error-specific path through the code, short-circuitiing functions all the way up the stack until handled.

Gym Etiquette 101

When I first started going to the gym, I was self-conscious every second. There’s a particular code of unwritten rules in the weightroom. Having a mentor really helps, and without one, it’s easy to be so uncomfortable that you don’t want to come back.

Over the years I’d like to think I’ve picked up most of the “rules”. Here’s a list I wish someone had given me when I was starting.

Careers in Programming

I recently visited Westville Correctional Facility, an Indiana penitentiary, to talk about jobs in the field of computing. It was an unusual opportunity that was honestly somewhat eye-opening; never have I had so enthusiastic and engaged an audience. I was sponsored through the Moreau College Initiative, a program in which residents of the facility are able to take full academic courses and potentially earn a bachelors degree before re-entering society. You can read more about the program here, if you are so interested.

Too Good To Be True?

The Too Good To Go app has been my fixation this summer. Since moving to a new neighborhood two months ago, I’ve picked up 43 surprise bags (all the more absurd because I didn’t discover the app until two weeks after moving). Dramatically increasing my consumption of sandwiches and pastries wasn’t in my original goals for the summer, but here we are. Too Good To Go lists “bags” that restaurants will sell you at a steep discount, though their contents will be a surprise.

Crafting Interpreters

In January, during some time off between jobs, I started working through Crafting Interpreters by Robert Nystrom. I think I originally discovered the book via r/ProgrammingLanguages. There aren’t that many accessible books for programming language design and implementation, so discovering the book (and that it was free to read online!1) was very exciting. It’s an absolutely incredible book, in which you learn about programming languages while implementing your own. The author describes himself as having been “bitten by the language bug years ago”.


Probably once a year, I end up back in the same discussion about timezones. I don’t like timezones and apparently I bring that up a lot. The Usual Griping Programmers' hatred for timezones is a bit of a meme. (I just googled “xkcd timezones” with absolute confidence there would be a comic, and of course I was right.) Computer systems don’t play nice with different times across the world. If I run a retail website, “weekend” sales should begin Saturday morning and end Sunday evening your time, even if it happens to mean that’s not the weekend where I am.

Is PyScript a Big Deal?

I went to PyCon a few weeks ago and while there, saw Peter Wang’s keynote on a new project called PyScript. PyScript is, essentially, a set of tools for running Python code in the browser – potentially even user-submitted code. I think that’s going to have a significant impact on the Python world, though maybe not in the way you’d first expect. Some Background For years now, various groups have been working on finding a way to “run” Python in the browser.

On the Road Trip

I recently returned from a 10-day road trip. Nowhere too exciting, just through the middle of the continental US: St. Louis, Memphis, northeast Arkansas, and Champaign (home of the University of Illinois Urbana-Champaign). People who know me probably wouldn’t describe me as the road trip type. But I had a few weeks off before I started a new job and the opportunity to travel without any commitments (or a finite amount of PTO) doesn’t present itself often; I figured that there would never be a better time to travel somewhat spontaneously.

Apartment Hunting with Python

I recently crossed the 9-month mark as a Chicago resident. The time has come for a big decision: renew my lease, or make the move to a new apartment?

I really like my current home. Two bedrooms, a back porch, a garage, and more grounded outlets than even a tech nerd like me could want. It’s in Little Italy, which is not a popular choice for Chicago young professionals, but is comfortable and has a decent set of restaurants. I suspect that a similar unit in a more “hip” neighborhood might be out of my price range. And my real office (as opposed to my extra bedroom, which has been serving in that capacity since I moved here) is a 10-minute bike ride away. The north side, home of many of those hip neighborhoods, would bring with it a commute at least twice as long.

On the other hand, my primary motivation in moving to a big city was exploration and experience. I wanted to get to know Chicago, particularly its neighborhoods. Moving would offer me a change of location, unlocking many new walkable or bikable destinations. Additionally, none of my friends live near my current apartment; most are in various parts of the northern neighborhoods, while I live somewhat south and west of the Loop (the downtown area of Chicago). Seeing most friends requires a 15+ minute drive or 30+ minute train ride.

There's More to Business Jargon than Meets the Eye

I suspect meetings at most American companies are full of jargon. There’s company- or industry-specific jargon: abbreviations or nicknames for common ideas (sometimes this is extended to the naming of internal teams as well). While frustrating to newcomers, these terms and phrases typically have a fair amount of value. Shorthands for industry-specific concepts are useful, both in time savings and added precision. A good example is MAU, monthly active users. Investors care a lot about who is using a product regularly, so this probably comes up regularly in Silicon Valley communications – both with the investors and within a company, as leadership pushes MAU as a proxy goal.

Running Better Meetings

In data science and engineering, technical skills are often the quickest way to early-career advancement – a new contributor who can write decent code is immediately an asset, in a way that a business-savvy developer with no coding ability is not. Companies often publicly espouse the benefits of softer skills, but that may not ring true in entry-level positions. In some technical fields, non-technical strengths can actually be viewed as negatives by peers, a betrayal of the ethos of the programmer.

Apple Music Had Its Chance

With the announcement of Apple One in September, I decided to reevaluate my loyalty to Spotify. If Apple was going to offer me a (slightly) discounted rate if I went all-in on their services, I wanted to have a good look at Apple Music and see if it could replace Spotify for me. After almost three months of use, my conclusion is that I could live with Apple Music, but I’d happily pay a small premium for Spotify instead.

Discovery Fiction

I recently discovered and binged the Ben, Ben and Blue podcast. The hosts all work in STEM education to some degree, and while that topic isn’t explicitly the focus of the show, it comes up a lot. In one episode, Grant Sanderson (one of the hosts) talks about how it’s tempting to teach new ideas by recapping the actual discovery of the concept as it happened. For example, I don’t know the exact details of the creation of the internet, but you could imagine an explanation that walks through the journey of universities wanting some kind of decentralized communication protocol, and how that effort was funded by government money with the justification that it could be useful for national defense.


For those not already in-the-know about Tony Horton’s infamous X-treme workout series, P90X was a collection of video workouts released in 2005. They’ve achieved something of a cult following in the years since, and Tony has returned in several reprisals – though none seem to have gained the fame of the original P90X. The workouts require minimal equipment: just a pull-up bar, a yoga mat, and a modest collection of dumbbells.

State of the Tools 2020: Hardware

I spend a lot of time on meta-productivity: thinking about how to get work done better and faster. The majority of that thinking is around technology and specifically the tech tools I use. Maybe thinking about my workflow has returns large enough to offset the time it consumes in my life, but frankly it doesn’t matter too much to me since life optimization is as much a hobby as an objective.

Analyzing My Runs

For a while now, I’ve been thinking about how interesting it would be to look at data on my running habits. Depending on the time of year and some other factors, I probably run 1-4 times a week, and I’ve been running semi-regularly since college.

For the vast majority of that time, I’ve recorded my runs in Under Armour’s MapMyRun app. It’s a bit buggy and feels non-native, but it has a good Apple Watch app and collects the information I need fairly reliably.

On the Good Things About Twitter

Over the past few years, I have heard many people repeatedly note the downsides of Twitter, particularly its impact on our society. I don’t agree with all of those criticisms, but some are legitimate and most deserve a serious discussion. This isn’t that discussion, though. Instead, I’d like to spend some time on the many merits of Twitter, so lost in our current debate. Good Writing Or: If I had more time, I would have written you a shorter tweet I have heard people say that a character limit forces brevity at the expense of thoughtful writing, but almost any good writing teacher would tell you that brief writing is thoughtful writing.

Scaling Data Science Across Python and R

My colleague Brad Boehmke and I made a guest appearance on the Talk Python to Me podcast to talk about the challenges of supporting a large data science department that uses both R and Python. You can listen to the episode on any podcast player.

Automation at 84.51˚

My colleague Dominick Ghirardo and I wrote a short piece for our company’s tech blog on approaching automation in data science.

Setting Up Raspberry Pis (the Full Version)

My Raspberry Pi

I’ve set up three Raspberry Pis over the last two days. By set up, I mean I burned the disk image to the SD card, got the Pi connected to the network and open to SSH, installed the tools I’m going to want every time, etc. Basically, make it just another identical worker node. I own six Pis total (for now), so I’ve done this before, and I’ll do it again. In fact, two of the installs I did were on Pis I’d owned for a while; I just wanted to wipe them and start fresh.

So after the first two this weekend took me a lot longer than they should have, I realized it was about time I documented my process and made it repeatable.

A Non-Gamer Takes on The Witcher 3

In March, I finally built a computer for the first time. I think this qualified as a seminal moment in the life of a young geek. I’ve enjoyed programming on my new “rig” quite a bit, but I also felt like it would be a waste not to try gaming on it.

So in early June, I pulled the trigger on a nice GPU (an EVGA GeForce GTX 1080) and, on the advice of a friend, purchased The Witcher 3: Wild Hunt. I’m not a gamer, so this was my first foray into the world of PC RPGs (Role Playing Games, for all you n000000bs out there). It was a glorious, incredibly high-definition experience.

Buzzer Beaters and Cognitive Bias

With Fernando Garcia, I recently cowrote an article for the Syntact Project on how cognitive bias manifests itself in sports and why awareness of your biases matters.

Web Speeds Trends

I published a longer piece on Syntact, exploring data on internet speeds gathered on a raspberry pi in my apartment.

Closed Minds. Full Schedules. Can't Learn.

For as long as I can remember, I didn’t like school. I didn’t hate it either, but it was always a drag. Grade school was somewhat tolerable, but adolescent awkwardness hit in junior high (switching to a new school didn’t help) and I can remember dreading each day. Then in high school, I came home every evening with a litany of complaints, usually about teachers and classwork and – more than anything else – just plain boredom. Though I loved my time in college, I skipped as much class as anyone. There were just too many sports to play, too many friends to keep up with, too many outside interests and projects that I wanted to pursue on my own. Lectures and labs were an unfortunate necessity, and for most courses, they were to be avoided when possible.