Python Community Interview

Python Community Interview With Will McGugan

by Ricky White community

Today I’m joined by Will McGugan. Will is a freelance Python developer based in Scotland and the creator of the popular Python library Rich.

In this interview, we discuss the origins of Rich, what it’s like to maintain a popular Python package, building chess engines, and Will’s love of photography.

Ricky: Thanks for joining me for this interview, Will. I’d like to start in the same manner we do with all our guests: how did you get into programming, and when did you start using Python?

Headshot of Will McGugan

Will: Thanks for having me on!

I discovered programming as a kid in the ’80s. For younger readers, it was exactly like Stranger Things, minus the CGI monsters. We had a ZX Spectrum+ computer back then. The graphics were flickery, and the sound was tinny, but I was hooked. At some point I discovered that you could type things on the keyboard and—if you did it just right—the computer would do as you told it.

Fast-forward a few years, and I’m working in the video games industry. I’m building a game engine and looking for a scripting language to handle the game mechanics while C++ does the graphics and heavy lifting. That’s when I came across Python, version 2.1, I think.

I didn’t consider it a proper programming language at the time, probably because it was too easy to use, and programming should be hard, right? Even so, I found myself coming back to Python for scripts and tools, which gradually became more sophisticated.

My “big break” in Python happened when I got a job working for the Internet Chess Club. They were looking for a Python developer to build a new chess interface. As luck would have it, I had already written a chess game and was eager to make better use of my Python skills. Since then, Python has been the main focus of my career, and I haven’t looked back.

Ricky: You’ve been a Python freelance developer for the last ten years. How has the Python freelance space changed over the last decade? And is it growing with Python’s popularity?

Will: My experience has been as a work-from-home freelancer. It’s pretty common these days, but when I started, it was really surprising to most people. If you are an experienced developer, you probably don’t need to work in an office anymore.

Python is mainstream now. Big tech firms adopted Python, and it’s gone from being a second language people use to boost productivity to an in-demand skill. I’m fortunate enough to have a long-term contract, but there doesn’t seem to be any shortage of contract work these days.

Ricky: People may know you as the creator of Rich, the increasingly popular library for formatting terminal output. What motivated you to create the library, and how has its increasing popularity (with over 619,000 downloads a month) affected the development of Rich?

Will: Rich was a long time in the making! Sometime in 2015, I was working on Moya, a web application platform and my side project at the time. Moya had a command-line application that could generate fancy terminal output.

The console class I implemented there turned out to be a prototypal version of Rich. This console class wasn’t all that well thought out—more of a dumping ground for anything terminal related—but there were some good ideas there.

After I stopped working on Moya, I intended to remake this uberconsole so that it could be used in other projects. Every time I struggled to read some poorly formatted output in the terminal, I would wish it already existed.

Sometime near the end of 2019, I started working on it. The first thing that came together was rich text, which is where the name came from. I had a class that could mark up spans of text with color and style in a similar way to HTML. A lot of the other features that came later were built on this core feature. I used it to implement syntax highlighting, tables, Markdown, and others.

When Rich started to get popular, the most obvious change was the volume of bugs and feature requests I was getting most days. I realized that Rich was no longer my plaything. People were using it in their day jobs, developers with clients and bosses and deadlines. I felt a sense of responsibility to fix bugs promptly and implement the features people asked for. To be honest, it started to feel less like a fun project to hack on in the evenings and more like a job.

There’s a certain sense of loss in that.

What kept me going was the positive feedback. A number of users said they found it fun to work with. I’m glad I persevered, because I like to see the creative ways people use Rich in their command-line apps.

Ricky: You recently added terminal dashboards to Rich, like htop, just much better looking! Is this a feature people were asking for? And what technical challenges do you face in its implementation?

Will: The terminal dashboards feature came about when I read a tweet about ghtop. This was a project started by Nat Friedman, the CEO of GitHub. Hamel Husain and Jeremy Howard used Rich to beautify the output of ghtop, and it looked great! Seeing that, I realized that Rich had a lot of potential for these kinds of interfaces.

To make these htop-like interfaces easier to implement, I added a layout class that could subdivide the terminal screen into parts, each with its own content.

The only real technical hurdle was that Rich wasn’t aware of height as a dimension. Output in Rich could have a width but assumed it could write as many lines as needed since the user could scroll up to see it. In a full-screen display you can’t scroll, so I had to restrict content to a fixed height. Fortunately, that wasn’t all that big of a change.

Ricky: How can people get started using Rich, and if they are already using it, how can they help the project continue to be successful?

Will: Rich is super easy to get started with. A one-liner, from rich import print, can replace the built-in print() with a print with superpowers. You get word wrapping, syntax highlighting, and pretty-printing for free. It’s not much more work to print things like tables, panels, and Markdown. The details are in the README and the docs, plus plenty of examples in the GitHub repository.

I’m currently trying out GitHub sponsors as a way of keeping up momentum with Rich. The first £200 a month will go to a bowel cancer charity. There are plenty of nonfinancial ways of helping with the project. Bug reports and feature suggestions are always welcome.

I’d also appreciate translations of the README, which is in five languages so far (including English). If the README isn’t in your native language, consider submitting a PR with the translation!

Ricky: Now just a few last questions. What else do you get up to in your spare time? What other hobbies and interests do you have aside from Python and programming?

Will: Before the pandemic, I really enjoyed wildlife photography. I’ve been fortunate enough to shoot amazing animals such as bears, Komodo dragons, and orangutans in their natural habitat. When the world returns to normal, I’d like to do a lot more of that.

Nowadays, my interests are a little closer to home. I enjoy cooking, mostly recipes I’ve seen on YouTube. Lately, I’ve been trying to master classic Italian pasta dishes.

Ricky: Thank you, Will, for joining me. Best of luck with Rich and its ongoing development.

If you’d like to get in touch with Will about anything we’ve talked about today, then you can contact him on Twitter. You might also like to get started with Rich.

If there’s someone in the Python community that you’d like me to interview, then leave a comment below or reach out to me on Twitter. Happy coding!

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Ricky White

Ricky is a software engineer and writer from a non-traditional background. He's an enthusiastic problem solver with passion for creating and building, from software and websites to books and bonsai.

» More about Ricky

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Master Real-World Python Skills With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

Master Real-World Python Skills
With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

What Do You Think?

Rate this article:

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.

Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

Keep Learning

Related Topics: community